How to add pdf thumbnails to ROX?

Word processors, spreadsheets, presentations, translation, etc.
Message
Author
musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#31 Post by musher0 »

Hello, all.

Now we know that the net-pbm package (the pnm/pam execs) does it to a point, that
convert command from ImageMagick does it. But Just to round up our horses on the
subject, does anybody know a way of creating jpg or png thumbnails of a pdf file
using the ghostscript included in most Puppies?

Thanks in advance.

musher0
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

#32 Post by MochiMoppel »

musher0 wrote:Now we know that the net-pbm package (the pnm/pam execs) does it to a point
No, we don't know that. Or did you manage to add pdf thumbnails to ROX?
does anybody know a way of creating jpg or png thumbnails of a pdf file
using the ghostscript included in most Puppies?
Yes, it's possible. Another and much easier option is to use pdftoppm, also included in most Puppies. But this will not help the OP. The point is that none of them produces png thumbnails in a format ROX is willing to use. ROX seems to ignore png files which don't contain metadata. IM is the only application I found that creates files which conform with ROX's picky format requirement.

musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#33 Post by musher0 »

Hello people!

This is the latest and probably last version of the script that I posted on the
previous page.

Code: Select all

#!/bin/sh
# Location and title: # ~/my-applications/bin/pdf2thumb-1a.sh
# Using apps from the netpbm kit.
# (c) musher0, 2014-12-17 to 19.
# Usage from cli: # pdf2thumb-1a.sh name_of.pdf
####
# set -xv # for debugging

# Vars
dirpath=${@%/*}
NOMFICHIER="`basename "$1" | cut -d. -f1`"

# Process
# We convert to ps
pdftops -f 1 -l 1 "$@"
cd $dirpath # because little netpbm execs work only with filename.

# Once more, to pnm
pstopnm -xsize=700 -ysize=900 -portrait $NOMFICHIER.ps
# Size parameters necessary for utilities below to work as expected.
# Specifying -dpi=300 seems to mess up things. So, no.

# The next little pnm* executables are pretty fussy, so 
# we have to take the winding road.

# We re-scale
for i in `ls -1 $NOMFICHIER*.ppm`;do
	pamscale 0.7 $i > "`basename $i | cut -d. -f1`".pnm
# Result is barely readable... 
# Still, for real thumbnails, parameter should be explored from 0.1 to 0.3
# to get a +/- 48x48 pixel size. If too small, resulting pnm file is invalid?
# Got errors here reporting an empty file for pamcut.
done

# We remove unwanted white space in borders.
for i in `ls -1 $NOMFICHIER*.pnm`;do
	pamcut -top=100 -right=400 $i > "`basename $i | cut -d. -f1`".pmm
done
# Convenient dummy extension for tmp file. Erased at end.

# We have to remember that picture size is changed by pstopnm, 
# then pamscale, then pamcut. All contribute to end result.

# Final conversion, to jpg
for i in `ls -1 $NOMFICHIER*.pmm`;do 
	pamtojpeg2k $i > "`basename $i | cut -d. -f1`".jpg
done
wait # until everything gets processed properly.

# Cleanup
rm -f *.p?m 
rm -f *.ps

# Display
mtpaint -v "$NOMFICHIER"00?.jpg # Image should be saved in mtpaint or
# defaultimageviewer "$NOMFICHIER"00?.jpg # won't load it.

# set +xv # We turn debuggging off.
It doesn't create real thumbnails, but the proportions are good. Who knows, someone
may find another use for it. Which is why I've included lots of comments that sum up
my experience.

BFN.

musher0
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

Post Reply