Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Mon 11 Dec 2017, 00:11
All times are UTC - 4
 Forum index » Advanced Topics » Additional Software (PETs, n' stuff) » Documents
How to add pdf thumbnails to ROX?
Post new topic   Reply to topic View previous topic :: View next topic
Page 3 of 3 [33 Posts]   Goto page: Previous 1, 2, 3
Author Message
musher0


Joined: 04 Jan 2009
Posts: 11251
Location: Gatineau (Qc), Canada

PostPosted: Thu 18 Dec 2014, 23:56    Post subject:  

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
~~~~~~~~~~
"Logical entities must not be multiplied beyond necessity." | |
« Il ne faut pas multiplier les entités logiques sans nécessité. » (Ockham)
Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 1397
Location: Japan

PostPosted: Fri 19 Dec 2014, 07:36    Post subject:  

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?
Quote:
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.
Back to top
View user's profile Send private message 
musher0


Joined: 04 Jan 2009
Posts: 11251
Location: Gatineau (Qc), Canada

PostPosted: Fri 19 Dec 2014, 07:40    Post subject:  

Hello people!

This is the latest and probably last version of the script that I posted on the
previous page.
Code:
#!/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
~~~~~~~~~~
"Logical entities must not be multiplied beyond necessity." | |
« Il ne faut pas multiplier les entités logiques sans nécessité. » (Ockham)
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 3 of 3 [33 Posts]   Goto page: Previous 1, 2, 3
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Advanced Topics » Additional Software (PETs, n' stuff) » Documents
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0368s ][ Queries: 14 (0.0081s) ][ GZIP on ]