Package: thumbnail
thumbnailThumbnail/Preview generator for 450 different filetypes in python.Pre-requisitesThis package has been thoroughly tested on Linux machines. If you're facing any issue post it on Github Issues.thumbnail depends on unoconv.(Universal Office converter)apt-getinstallunoconvthumbnail depends of ffmpeg for audio or video filesapt-getinstallffmpegthumbnail depends on Imagemagick for image manipulationapt-getinstallimagemagickthumbnail also needs curl to be installledapt-getinstallcurlTo install this package:pipinstallthumbnailHow to useSample code:fromthumbnailimportgenerate_thumbnail//generate_thumbnail(input,output,options)options={'trim':False,'height':300,'width':300,'quality':85,'type':'thumbnail'}generate_thumbnil('sample.docx','./thumbnails/thumbnail.png',options)You need to pass three parameters in generate_thumbnail function.input: location of the input file. You can see the list of supported files at the end.output: location of the to be generated thumbnail file. It can be .png, .jpg or .gifoptions: It can have five diff parameters. If you don't want to pass any options, pass options as a blank {}trim: Boolean(default = True)
It'll automatically trim your file.height: Integer(default = 300)
Height of the thumbnail in px.width: Integer(default = 300)
Width of the thumbnail in px.quality: Integer(default = 85)
Quality of the thumbnail on a scale of 1-100.type: String(default = "thumbnail"
It takes two values "thumbnail" or "firstpage"
"thumbnail" = 300X300 image of the first page of the document. Height and Width can be changed by providing values in options
"firstpage" = snapshot of the document's first page.Common IssuesImageMagick no images defined:Open /etc/ImageMagick-6/policy.xml in the editor of your choice<!--Findthisline(shouldbeintheendoffile)-->
<policydomain="coder"rights="none"pattern="PDF"/>You can either comment it or change rights to "read | write"Reference:https://askubuntu.com/questions/1181762/imagemagickconvert-im6-q16-no-images-definedunoconv: Cannot find a suitable pyuno library and python binary combination in /usr/lib/libreoffice:Open /usr/bin/unoconv in the editor of your choiceReplace #!/usr/bin/env python3 with #!/usr/bin/python3Reference:https://github.com/unoconv/unoconv/issues/405This package is inspired from npm module filepreview.Supported document typesThe following list of document formats are currently available for exporting to:bib - BibTeX [.bib]doc - Microsoft Word 97/2000/XP [.doc]doc6 - Microsoft Word 6.0 [.doc]doc95 - Microsoft Word 95 [.doc]docbook - DocBook [.xml]html - HTML Document (OpenOffice.org Writer) [.html]odt - Open Document Text [.odt]ott - Open Document Text [.ott]ooxml - Microsoft Office Open XML [.xml]pdb - AportisDoc (Palm) [.pdb]pdf - Portable Document Format [.pdf]psw - Pocket Word [.psw]rtf - Rich Text Format [.rtf]latex - LaTeX 2e [.ltx]sdw - StarWriter 5.0 [.sdw]sdw4 - StarWriter 4.0 [.sdw]sdw3 - StarWriter 3.0 [.sdw]stw - Open Office.org 1.0 Text Document Template [.stw]sxw - Open Office.org 1.0 Text Document [.sxw]text - Text Encoded [.txt]txt - Plain Text [.txt]vor - StarWriter 5.0 Template [.vor]vor4 - StarWriter 4.0 Template [.vor]vor3 - StarWriter 3.0 Template [.vor]xhtml - XHTML Document [.html]The following list of graphics formats are currently available for exporting to:bmp - Windows Bitmap [.bmp]emf - Enhanced Metafile [.emf]eps - Encapsulated PostScript [.eps]gif - Graphics Interchange Format [.gif]html - HTML Document (OpenOffice.org Draw) [.html]jpg - Joint Photographic Experts Group [.jpg]met - OS/2 Metafile [.met]odd - OpenDocument Drawing [.odd]otg - OpenDocument Drawing Template [.otg]pbm - Portable Bitmap [.pbm]pct - Mac Pict [.pct]pdf - Portable Document Format [.pdf]pgm - Portable Graymap [.pgm]png - Portable Network Graphic [.png]ppm - Portable Pixelmap [.ppm]ras - Sun Raster Image [.ras]std - OpenOffice.org 1.0 Drawing Template [.std]svg - Scalable Vector Graphics [.svg]svm - StarView Metafile [.svm]swf - Macromedia Flash (SWF) [.swf]sxd - OpenOffice.org 1.0 Drawing [.sxd]sxd3 - StarDraw 3.0 [.sxd]sxd5 - StarDraw 5.0 [.sxd]tiff - Tagged Image File Format [.tiff]vor - StarDraw 5.0 Template [.vor]vor3 - StarDraw 3.0 Template [.vor]wmf - Windows Metafile [.wmf]xhtml - XHTML [.xhtml]xpm - X PixMap [.xpm]The following list of presentation formats are currently available for exporting to:bmp - Windows Bitmap [.bmp]emf - Enhanced Metafile [.emf]eps - Encapsulated PostScript [.eps]gif - Graphics Interchange Format [.gif]html - HTML Document (OpenOffice.org Impress) [.html]jpg - Joint Photographic Experts Group [.jpg]met - OS/2 Metafile [.met]odd - OpenDocument Drawing (Impress) [.odd]odg - OpenOffice.org 1.0 Drawing (OpenOffice.org Impress) [.odg]odp - OpenDocument Presentation [.odp]pbm - Portable Bitmap [.pbm]pct - Mac Pict [.pct]pdf - Portable Document Format [.pdf]pgm - Portable Graymap [.pgm]png - Portable Network Graphic [.png]pot - Microsoft PowerPoint 97/2000/XP Template [.pot]ppm - Portable Pixelmap [.ppm]ppt - Microsoft PowerPoint 97/2000/XP [.ppt]pwp - PlaceWare [.pwp]ras - Sun Raster Image [.ras]sda - StarDraw 5.0 (OpenOffice.org Impress) [.sda]sdd - StarImpress 5.0 [.sdd]sdd3 - StarDraw 3.0 (OpenOffice.org Impress) [.sdd]sdd4 - StarImpress 4.0 [.sdd]sti - OpenOffice.org 1.0 Presentation Template [.sti]stp - OpenDocument Presentation Template [.stp]svg - Scalable Vector Graphics [.svg]svm - StarView Metafile [.svm]swf - Macromedia Flash (SWF) [.swf]sxi - OpenOffice.org 1.0 Presentation [.sxi]tiff - Tagged Image File Format [.tiff]vor - StarImpress 5.0 Template [.vor]vor3 - StarDraw 3.0 Template (OpenOffice.org Impress) [.vor]vor4 - StarImpress 4.0 Template [.vor]vor5 - StarDraw 5.0 Template (OpenOffice.org Impress) [.vor]wmf - Windows Metafile [.wmf]xhtml - XHTML [.xml]xpm - X PixMap [.xpm]The following list of spreadsheet formats are currently available for exporting to:csv - Text CSV [.csv]dbf - dBase [.dbf]dif - Data Interchange Format [.dif]html - HTML Document (OpenOffice.org Calc) [.html]ods - Open Document Spreadsheet [.ods]ooxml - Microsoft Excel 2003 XML [.xml]pdf - Portable Document Format [.pdf]pts - OpenDocument Spreadsheet Template [.pts]pxl - Pocket Excel [.pxl]sdc - StarCalc 5.0 [.sdc]sdc4 - StarCalc 4.0 [.sdc]sdc3 - StarCalc 3.0 [.sdc]slk - SYLK [.slk]stc - OpenOffice.org 1.0 Spreadsheet Template [.stc]sxc - OpenOffice.org 1.0 Spreadsheet [.sxc]vor3 - StarCalc 3.0 Template [.vor]vor4 - StarCalc 4.0 Template [.vor]vor - StarCalc 5.0 Template [.vor]xhtml - XHTML [.xhtml]xls - Microsoft Excel 97/2000/XP [.xls]xls5 - Microsoft Excel 5.0 [.xls]xls95 - Microsoft Excel 95 [.xls]xlt - Microsoft Excel 97/2000/XP Template [.xlt]xlt5 - Microsoft Excel 5.0 Template [.xlt]xlt95 - Microsoft Excel 95 Template [.xlt]The following list of open office formats are currently available for exporting to:Microsoft Word 6.0/95/97/2000/XP (.doc and .dot)Microsoft Word 2003 XML (.xml)Microsoft Word 2007 XML (.docx, .docm, .dotx, .dotm)Microsoft WinWord 5 (.doc)WordPerfect Document (.wpd)WPS 2000/Office 1.0 (.wps).rtf, .txt, and .csvStarWriter formats (.sdw, .sgl, .vor)DocBook (.xml)Unified Office Format text (.uot, .uof)Ichitaro 8/9/10/11 (.jtd and .jtt)Hangul WP 97 (.hwp)T602 Document (.602, .txt)AportisDoc (Palm) (.pdb)Pocket Word (.psw)Microsoft Excel 97/2000/XP (.xls, .xlw, and .xlt)Microsoft Excel 4.x–5.0/95 (.xls, .xlw, and .xlt)Microsoft Excel 2003 XML (.xml)Microsoft Excel 2007 XML (.xlsx, .xlsm, .xltx, .xltm)Microsoft Excel 2007 binary (.xlsb)Lotus 1-2-3 (.wk1, .wks, and .123)Data Interchange Format (.dif)Rich Text Format (.rtf)Text CSV (.csv and .txt)StarCalc formats (.sdc and .vor)dBASE (.dbf)SYLK (.slk)Unified Office Format spreadsheet (.uos, .uof).htm and .html files, including Web page queriesPocket Excel (pxl)Quattro Pro 6.0 (.wb2)Microsoft PowerPoint 97/2000/XP (.ppt, .pps, and .pot)Microsoft PowerPoint 2007 (.pptx, .pptm, .potx, .potm)StarDraw and StarImpress (.sda, .sdd, .sdp, and .vor)Unified Office Format presentation (.uop, .uof)CGM – Computer Graphics Metafile (.cgm)Portable Document Format (.pdf)The following list of video formats are currently available for exporting to:3g2 3GP2 (3GPP2 file format)3gp 3GP (3GPP file format)4xm 4X Technologiesa64 a64 - video for Commodore 64aac raw ADTS AAC (Advanced Audio Coding)ac3 raw AC-3act ACT Voice file formatadf Artworx Data Formatadp ADPadts ADTS AAC (Advanced Audio Coding)adx CRI ADXaea MD STUDIO audioafc AFCaiff Audio IFFalaw PCM A-lawalias_pix Alias/Wavefront PIX imagealsa ALSA audio outputamr 3GPP AMRanm Deluxe Paint Animationapc CRYO APCape Monkey's Audioapng Animated Portable Network Graphicsaqtitle AQTitle subtitlesasf ASF (Advanced / Active Streaming Format)asf_stream ASF (Advanced / Active Streaming Format)ass SSA (SubStation Alpha) subtitleast AST (Audio Stream)au Sun AUavi AVI (Audio Video Interleaved)avisynth AviSynth scriptavm2 SWF (ShockWave Flash) (AVM2)avr AVR (Audio Visual Research)avs AVSbethsoftvid Bethesda Softworks VIDbfi Brute Force & Ignorancebin Binary textbink Binkbit G.729 BIT file formatbmp_pipe piped bmp sequencebmv Discworld II BMVboa Black Ops Audiobrender_pix BRender PIX imagebrstm BRSTM (Binary Revolution Stream)c93 Interplay C93caca caca (color ASCII art) output devicecaf Apple CAF (Core Audio Format)cavsvideo raw Chinese AVS (Audio Video Standard) videocdg CD Graphicscdxl Commodore CDXL videocine Phantom Cineconcat Virtual concatenation scriptcrc CRC testingdash DASH Muxerdata raw datadaud D-Cinema audiodfa Chronomaster DFAdirac raw Diracdnxhd raw DNxHD (SMPTE VC-3)dpx_pipe piped dpx sequencedsf DSD Stream File (DSF)dsicin Delphine Software International CINdss Digital Speech Standard (DSS)dts raw DTSdtshd raw DTS-HDdv DV (Digital Video)dv1394 DV1394 A/V grabdvbsub raw dvbsubdvd MPEG-2 PS (DVD VOB)dxa DXAea Electronic Arts Multimediaea_cdata Electronic Arts cdataeac3 raw E-AC-3epaf Ensoniq Paris Audio Fileexr_pipe piped exr sequencef32be PCM 32-bit floating-point big-endianf32le PCM 32-bit floating-point little-endianf4v F4V Adobe Flash Videof64be PCM 64-bit floating-point big-endianf64le PCM 64-bit floating-point little-endianfbdev Linux framebufferffm FFM (FFserver live feed)ffmetadata FFmpeg metadata in textfilm_cpk Sega FILM / CPKfilmstrip Adobe Filmstripflac raw FLACflic FLI/FLC/FLX animationflv FLV (Flash Video)framecrc framecrc testingframemd5 Per-frame MD5 testingfrm Megalux Frameg722 raw G.722g723_1 raw G.723.1g729 G.729 raw format demuxergif GIF Animationgsm raw GSMgxf GXF (General eXchange Format)h261 raw H.261h263 raw H.263h264 raw H.264 videohds HDS Muxerhevc raw HEVC videohls Apple HTTP Live Streaminghls,applehttp Apple HTTP Live Streaminghnm Cryo HNM v4ico Microsoft Windows ICOidcin id Cinematicidf iCE Draw Fileiec61883 libiec61883 (new DV1394) A/V input deviceiff IFF (Interchange File Format)ilbc iLBC storageimage2 image2 sequenceimage2pipe piped image2 sequenceingenient raw Ingenient MJPEGipmovie Interplay MVEipod iPod H.264 MP4 (MPEG-4 Part 14)ircam Berkeley/IRCAM/CARL Sound Formatismv ISMV/ISMA (Smooth Streaming)iss Funcom ISSiv8 IndigoVision 8000 videoivf On2 IVFj2k_pipe piped j2k sequencejack JACK Audio Connection Kitjacosub JACOsub subtitle formatjpeg_pipe piped jpeg sequencejpegls_pipe piped jpegls sequencejv Bitmap Brothers JVlatm LOAS/LATMlavfi Libavfilter virtual input devicelibcdiolibdc1394 dc1394 v.2 A/V grablibgme Game Music Emu demuxerlibmodplug ModPlug demuxerlive_flv live RTMP FLV (Flash Video)lmlm4 raw lmlm4loas LOAS AudioSyncStreamlrc LRC lyricslvf LVFlxf VR native stream (LXF)m4v raw MPEG-4 videomatroska Matroskamatroska,webm Matroska / WebMmd5 MD5 testingmgsts Metal Gear Solid: The Twin Snakesmicrodvd MicroDVD subtitle formatmjpeg raw MJPEG videomkvtimestamp_v2 extract pts as timecode v2 format, as defined by mkvtoolnixmlp raw MLPmlv Magic Lantern Video (MLV)mm American Laser Games MMmmf Yamaha SMAFmov QuickTime / MOVmov,mp4,m4a,3gp,3g2,mj2 QuickTime / MOVmp2 MP2 (MPEG audio layer 2)mp3 MP3 (MPEG audio layer 3)mp4 MP4 (MPEG-4 Part 14)mpc Musepackmpc8 Musepack SV8mpeg MPEG-1 Systems / MPEG program streammpeg1video raw MPEG-1 videompeg2video raw MPEG-2 videompegts MPEG-TS (MPEG-2 Transport Stream)mpegtsraw raw MPEG-TS (MPEG-2 Transport Stream)mpegvideo raw MPEG videompjpeg MIME multipart JPEGmpl2 MPL2 subtitlesmpsub MPlayer subtitlesmsnwctcp MSN TCP Webcam streammtv MTVmulaw PCM mu-lawmv Silicon Graphics Moviemvi Motion Pixels MVImxf MXF (Material eXchange Format)mxf_d10 MXF (Material eXchange Format) D-10 Mappingmxf_opatom MXF (Material eXchange Format) Operational Pattern Atommxg MxPEG clipnc NC camera feednistsphere NIST SPeech HEader REsourcesnsv Nullsoft Streaming Videonut NUTnuv NuppelVideooga Ogg Audioogg Oggoma Sony OpenMG audioopenal OpenAL audio capture deviceopengl OpenGL outputopus Ogg Opusoss OSS (Open Sound System) playbackpaf Amazing Studio Packed Animation Filepictor_pipe piped pictor sequencepjs PJS (Phoenix Japanimation Society) subtitlespmp Playstation Portable PMPpng_pipe piped png sequencepsp PSP MP4 (MPEG-4 Part 14)psxstr Sony Playstation STRpulse Pulse audio outputpva TechnoTrend PVApvf PVF (Portable Voice Format)qcp QCPqdraw_pipe piped qdraw sequencer3d REDCODE R3Drawvideo raw videorealtext RealText subtitle formatredspark RedSparkrl2 RL2rm RealMediaroq raw id RoQrpl RPL / ARMoviersd GameCube RSDrso Lego Mindstorms RSOrtp RTP outputrtp_mpegts RTP/mpegts output formatrtsp RTSP outputs16be PCM signed 16-bit big-endians16le PCM signed 16-bit little-endians24be PCM signed 24-bit big-endians24le PCM signed 24-bit little-endians32be PCM signed 32-bit big-endians32le PCM signed 32-bit little-endians8 PCM signed 8-bitsami SAMI subtitle formatsap SAP outputsbg SBaGen binaural beats scriptsdl SDL output devicesdp SDPsdr2 SDR2segment segmentsgi_pipe piped sgi sequenceshn raw Shortensiff Beam Software SIFFsinglejpeg JPEG single imagesln Asterisk raw pcmsmjpeg Loki SDL MJPEGsmk Smackersmoothstreaming Smooth Streaming Muxersmush LucasArts Smushsol Sierra SOLsox SoX nativespdif IEC 61937 (used on S/PDIF - IEC958)spx Ogg Speexsrt SubRip subtitlestl Spruce subtitle formatstream_segment,ssegment streaming segment muxersubviewer SubViewer subtitle formatsubviewer1 SubViewer v1 subtitle formatsunrast_pipe piped sunrast sequencesup raw HDMV Presentation Graphic Stream subtitlessvcd MPEG-2 PS (SVCD)swf SWF (ShockWave Flash)tak raw TAKtedcaptions TED Talks captionstee Multiple muxer teethp THPtiertexseq Tiertex Limited SEQtiff_pipe piped tiff sequencetmv 8088flex TMVtruehd raw TrueHDtta TTA (True Audio)tty Tele-typewritertxd Renderware TeXture Dictionaryu16be PCM unsigned 16-bit big-endianu16le PCM unsigned 16-bit little-endianu24be PCM unsigned 24-bit big-endianu24le PCM unsigned 24-bit little-endianu32be PCM unsigned 32-bit big-endianu32le PCM unsigned 32-bit little-endianu8 PCM unsigned 8-bituncodedframecrc uncoded framecrc testingv4l2 Video4Linux2 output devicevc1 raw VC-1 videovc1test VC-1 test bitstreamvcd MPEG-1 Systems / MPEG program stream (VCD)video4linux2,v4l2 Video4Linux2 device grabvivo Vivovmd Sierra VMDvob MPEG-2 PS (VOB)vobsub VobSub subtitle formatvoc Creative Voicevplayer VPlayer subtitlesvqf Nippon Telegraph and Telephone Corporation (NTT) TwinVQw64 Sony Wave64wav WAV / WAVE (Waveform Audio)wc3movie Wing Commander III moviewebm WebMwebm_chunk WebM Chunk Muxerwebm_dash_manifest WebM DASH Manifestwebp WebPwebp_pipe piped webp sequencewebvtt WebVTT subtitlewsaud Westwood Studios audiowsvqa Westwood Studios VQAwtv Windows Television (WTV)wv raw WavPackx11grab X11 screen capture, using XCBxa Maxis XAxbin eXtended BINary text (XBIN)xmv Microsoft XMVxv XV (XVideo) output devicexwma Microsoft xWMAyop Psygnosis YOPyuv4mpegpipe YUV4MPEG pipe