Now you tell me! Ok, guys, version 2 coming up!Puppus Dogfellow wrote:musher, [...] is there a way to limit it to just the first page? i think the main purpose of a preview thumbnail is to give a document a unique icon that helps identify its contents and visually differentiate similarly titled files, in which case the cover shot (so to speak) should be enough. [... ]
How to add pdf thumbnails to ROX?
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)
Hi, guys.
Best I can do ATM taking into consideration the remarks of both of you. For some
reason, if the # of p. is limited to 1 in pdftops, later, pmnmscale doesn't like ti. So
we have 2 pages minimum. Also, I don't like the wide whitespace at the top and at
the right, and the guilty program should be hunted down later. Finally, if we want to
be able to read the content, IMO, these are not "thumbnails" anymore, simply
"reduced-size images".
Which is why it's not version 2 yet, only version 1a! Sorry. Again, you're welcome
to fiddle with the script to improve it. BFN.
musher0
Best I can do ATM taking into consideration the remarks of both of you. For some
reason, if the # of p. is limited to 1 in pdftops, later, pmnmscale doesn't like ti. So
we have 2 pages minimum. Also, I don't like the wide whitespace at the top and at
the right, and the guilty program should be hunted down later. Finally, if we want to
be able to read the content, IMO, these are not "thumbnails" anymore, simply
"reduced-size images".
Which is why it's not version 2 yet, only version 1a! Sorry. Again, you're welcome
to fiddle with the script to improve it. BFN.
musher0
#!/bin/sh
# Location and title:
# ~/my-applications/bin/pdf2thumb-1a.sh
# Version 1a, for Semme and PuppusDogfellow!
# (c) musher0, 2014-12-17
####
# set -xv
dirpath=${@%/*}
NOMFICHIER="`basename "$1" | cut -d. -f1`"
pdftops -f 1 -l 2 "$@"
cd $dirpath
pstopnm -xsize=700 -ysize=900 -portrait $NOMFICHIER.ps
# -dpi=300, no.
# These little pnm* executables are pretty fussy, so
# we have to take the winding road.
for i in `ls -1 $NOMFICHIER*.ppm`;do
pnmscale 0.9 $i > "`basename $i | cut -d. -f1`".pnm
# This is barely readable... # Still, for real thumbnails, parameter should be from 0.1 to 0.3.
done
for i in `ls -1 $NOMFICHIER*.pnm`;do
pnmtojpeg $i > "`basename $i | cut -d. -f1`".jpg
done
wait
rm -f *.p?m
rm -f *.ps
mtpaint -v "$NOMFICHIER"00?.jpg || defaultimageviewer "$NOMFICHIER"00?.jpg
# set +xv
####
# Final note.
# Usage from cli:
# pdf2thumb.sh <nameof>.pdf
- Attachments
-
- article001.jpg
- I removed about an inch of whitespace at the top and right borders...
Readable... barely. :) - (60.39 KiB) Downloaded 273 times
Last edited by musher0 on Wed 17 Dec 2014, 22:49, edited 1 time in total.
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)
Hi Semme.Semme wrote:To our OP, Dosh.. What's the *target icon size* here, and *where* are
you accustomed to viewing such a preview?
I'd suggest that Dosh is a WhineDose refugee. WhineDose Explorer has it and a couple of
document organiszers in WhineDose * Seven.
musher0
~~~~~~~
* The OS that Whines if it doesn't get it's Dose (of anti-something). Hey, man, fear
sells! (It's not just sex anymore !) .
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)
Hello again.
If you install this netpbm pet from
http://murga-linux.com/puppy/viewtopic. ... 552#815552
you'll be able to run this:
with this result (see pic). You'll notice that this new script uses pamscale, pamcut and
pamtojpeg2k from the recent netpbm-10.67 suite. These newer utilities allow us to get
a much better balanced page.
Final note: the resulting jpg image (of the script process) needs to be loaded and
saved in mtpaint before it can be shown proprely in gpicview or gqview.
BFN.
musher0
If you install this netpbm pet from
http://murga-linux.com/puppy/viewtopic. ... 552#815552
you'll be able to run this:
Code: Select all
#!/bin/sh
# Location and title:
# ~/my-applications/bin/pdf2thumb-1b.sh
# (c) musher0, 2014-12-17
####
# set -xv
dirpath=${@%/*}
NOMFICHIER="`basename "$1" | cut -d. -f1`"
pdftops -f 1 -l 2 "$@"
cd $dirpath
pstopnm -xsize=700 -ysize=900 -portrait $NOMFICHIER.ps
# -dpi=300, no.
# These little pnm* executables are pretty fussy, so
# we have to take the winding road.
for i in `ls -1 $NOMFICHIER*.ppm`;do
pamscale 0.9 $i > "`basename $i | cut -d. -f1`".pnm
# This is barely readable...
# Still, for real thumbnails, parameter can be from 0.1 to 0.3
done
for i in `ls -1 $NOMFICHIER*.pnm`;do
pamcut -top=150 -right=500 $i > "`basename $i | cut -d. -f1`".pmm
done
for i in `ls -1 $NOMFICHIER*.pmm`;do
pamtojpeg2k $i > "`basename $i | cut -d. -f1`".jpg
done
wait
rm -f *.p?m
rm -f *.ps
mtpaint -v "$NOMFICHIER"00?.jpg
# defaultimageviewer "$NOMFICHIER"00?.jpg
# set +xv
####
# Final note.
# Usage from cli:
# pdf2thumb.sh <nameof>.pdf
pamtojpeg2k from the recent netpbm-10.67 suite. These newer utilities allow us to get
a much better balanced page.
Final note: the resulting jpg image (of the script process) needs to be loaded and
saved in mtpaint before it can be shown proprely in gpicview or gqview.
BFN.
musher0
- Attachments
-
- article001.jpg
- Now that's better! (Thanks to pamcut.)
- (52.7 KiB) Downloaded 237 times
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)
Got an example picture?slavvo67 wrote:Imagemagick can create a thumb.png easily. Just how to script to attach it as an icon instead of drag and drop. file below is the file name of pdf. [0] represents page 1 of the pdf. thumb.png is the thumbnail.
convert -thumbnail x80 file.pdf[0] thumb.png
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)
k2pdfopt
Hey Musher0, the image manipulation in your script seems to lead towards the capabilities of k2pdfopt, are you aware of it?
http://www.willus.com/k2pdfopt/
It's a kindle tool but
http://www.willus.com/k2pdfopt/
It's a kindle tool but
Source code is available.k2pdf homepage wrote:It can also be used as a general PDF copying/cropping/re-sizing/OCR-ing manipulation tool. It can generate native or bitmapped PDF output...
[url=http://murga-linux.com/puppy/viewtopic.php?t=117546]Fatdog64-810[/url]|[url=http://goo.gl/hqZtiB]+Packages[/url]|[url=http://goo.gl/6dbEzT]Kodi[/url]|[url=http://goo.gl/JQC4Vz]gtkmenuplus[/url]
- MochiMoppel
- Posts: 2084
- Joined: Wed 26 Jan 2011, 09:06
- Location: Japan
Re: How to add pdf thumbnails to ROX?
For all documents? Well, let's start with PDFs.dosh2684 wrote:i'd like to know if there is in any way for me to view thumbnails for all documents namely pdfs texts docs...
slavvo67 suggests Imagemagick, which probably is your best choice for command line image manipulation:
Now let's put this to use and create thumbnails for ROX:slavvo67 wrote:Imagemagick can create a thumb.png easily....
convert -thumbnail x80 file.pdf[0] thumb.png
Step 1: Create a folder /root/.config/rox.sourceforge.net/MIME-thumb
Step 2: In this folder create a script with name application_pdf:
Code: Select all
#! /bin/sh
exec convert -thumbnail x"$3" "$1"[0] "$2"
- Attachments
-
- ROX_pdf_thumbnails.png
- (32.64 KiB) Downloaded 219 times
Hello again, people.musher0 wrote:For the record, this java app generates thumbnails as well as bookmarks.
http://flavianopetrocchi.blogspot.ca/
It's also one of the best PDF readers out there, except it's not advertised as such.
As opposed to Puppy's epdfview, it has no problem displaying images embedded
in the pdf file.You need to have a java JRE installed to run it, though.
@MochiMoppei : Many thanks for the handy ImageMagick one-liner.
BFN.
mushero
- Attachments
-
- epdfview-example.jpg
- (37.06 KiB) Downloaded 184 times
-
- jpdfbookmarks-example.jpg
- (56.74 KiB) Downloaded 187 times
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)
Mochi nailed it! IM's also one of the most flexible and efficient screenshot utilities, bar none.
>>> Living with the immediacy of death helps you sort out your priorities. It helps you live a life less trivial <<<
Hi Mochi,
Suppose I don't want to include the name when executing the script. So, maybe I want to execute like I had it but pass the icon to ROX. Is there another way? Something, let's say, similar to my example posted above but taking that png and just passing it to the file in rox as an icon? I'm guessing that's where the $2 comes into play in your script.
This way, you could batch convert a whole directory.
Slavvo67
Suppose I don't want to include the name when executing the script. So, maybe I want to execute like I had it but pass the icon to ROX. Is there another way? Something, let's say, similar to my example posted above but taking that png and just passing it to the file in rox as an icon? I'm guessing that's where the $2 comes into play in your script.
This way, you could batch convert a whole directory.
Slavvo67
- MochiMoppel
- Posts: 2084
- Joined: Wed 26 Jan 2011, 09:06
- Location: Japan
I'm afraid I have no idea what you meanslavvo67 wrote:Suppose I don't want to include the name when executing the script. So, maybe I want to execute like I had it but pass the icon to ROX. Is there another way?
ROX always batch converts the whole directory when you switch to thumbnail view. Please keep in mind that the script is run by ROX, so there is nothing for you to execute.This way, you could batch convert a whole directory.
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
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)
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)
- MochiMoppel
- Posts: 2084
- Joined: Wed 26 Jan 2011, 09:06
- Location: Japan
No, we don't know that. Or did you manage to add pdf thumbnails to ROX?musher0 wrote:Now we know that the net-pbm package (the pnm/pam execs) does it to a point
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.does anybody know a way of creating jpg or png thumbnails of a pdf file
using the ghostscript included in most Puppies?
Hello people!
This is the latest and probably last version of the script that I posted on the
previous page.
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
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.
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)
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)