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 Thu 14 Dec 2017, 13: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 2 of 3 [33 Posts]   Goto page: Previous 1, 2, 3 Next
Author Message
musher0


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

PostPosted: Wed 17 Dec 2014, 11:53    Post subject:  

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. [... ]


Now you tell me! Smile Ok, guys, version 2 coming up! Smile

_________________
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 
musher0


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

PostPosted: Wed 17 Dec 2014, 13:25    Post subject:  

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

Quote:
#!/bin/sh
# Location and title:
# ~/my-applications/bin/pdf2thumb-1a.sh
# Version 1a, for Semme and PuppusDogfellow! Wink
# (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
article001.jpg
 Description   I removed about an inch of whitespace at the top and right borders...
Readable... barely. :)
 Filesize   60.39 KB
 Viewed   237 Time(s)

article001.jpg


_________________
musher0
~~~~~~~~~~
"Logical entities must not be multiplied beyond necessity." | |
« Il ne faut pas multiplier les entités logiques sans nécessité. » (Ockham)

Last edited by musher0 on Wed 17 Dec 2014, 18:49; edited 1 time in total
Back to top
View user's profile Send private message 
musher0


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

PostPosted: Wed 17 Dec 2014, 13:43    Post subject:  

Re-reading the title:
the script produces "thumbnails" NOT integrated to ROX...
Oh well...

_________________
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 
Semme


Joined: 07 Aug 2011
Posts: 7775
Location: World_Hub

PostPosted: Wed 17 Dec 2014, 16:33    Post subject:  

To our OP, Dosh.. What's the *target icon size* here, and *where* are you accustomed to viewing such a preview?
_________________
>>> Living with the immediacy of death helps you sort out your priorities. It helps you live a life less trivial <<<
Back to top
View user's profile Send private message 
musher0


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

PostPosted: Wed 17 Dec 2014, 18:43    Post subject:  

Semme wrote:
To our OP, Dosh.. What's the *target icon size* here, and *where* are
you accustomed to viewing such a preview?


Hi Semme.

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 !) Twisted Evil .

_________________
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 
musher0


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

PostPosted: Wed 17 Dec 2014, 20:54    Post subject:  

Hello again.

If you install this netpbm pet from
http://murga-linux.com/puppy/viewtopic.php?p=815552#815552
you'll be able to run this:
Code:
#!/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


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
article001.jpg
 Description   Now that's better! (Thanks to pamcut.)
 Filesize   52.7 KB
 Viewed   196 Time(s)

article001.jpg


_________________
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 
slavvo67

Joined: 12 Oct 2012
Posts: 1434
Location: The other Mr. 305

PostPosted: Thu 18 Dec 2014, 00:03    Post subject:  

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


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

PostPosted: Thu 18 Dec 2014, 00:47    Post subject:  

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


Got an example picture? Smile

_________________
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 
step

Joined: 04 May 2012
Posts: 953

PostPosted: Thu 18 Dec 2014, 02:36    Post subject: 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
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...

Source code is available.

_________________
Fatdog64-710|+Packages|Kodi|Findnrun|+forum|gtkmenuplus
Back to top
View user's profile Send private message 
musher0


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

PostPosted: Thu 18 Dec 2014, 05:03    Post subject:  

Hi, step.

No, I didn't know k2pdfopt existed. Thanks for the info.

Best regards.

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: 1398
Location: Japan

PostPosted: Thu 18 Dec 2014, 05:22    Post subject: Re: How to add pdf thumbnails to ROX?
Subject description: Or any file manager
 

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...
For all documents? Well, let's start with PDFs.

slavvo67 suggests Imagemagick, which probably is your best choice for command line image manipulation:
slavvo67 wrote:
Imagemagick can create a thumb.png easily....
convert -thumbnail x80 file.pdf[0] thumb.png


Now let's put this to use and create thumbnails for ROX:
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:
#! /bin/sh
exec convert -thumbnail x"$3" "$1"[0] "$2"

That's all Wink
ROX_pdf_thumbnails.png
 Description   
 Filesize   32.64 KB
 Viewed   179 Time(s)

ROX_pdf_thumbnails.png

Back to top
View user's profile Send private message 
musher0


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

PostPosted: Thu 18 Dec 2014, 06:29    Post subject:  

musher0 wrote:
For the record, this java app generates thumbnails as well as bookmarks.
http://flavianopetrocchi.blogspot.ca/

Hello again, people.

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. Smile

BFN.

mushero
epdfview-example.jpg
 Description   
 Filesize   37.06 KB
 Viewed   149 Time(s)

epdfview-example.jpg

jpdfbookmarks-example.jpg
 Description   
 Filesize   56.74 KB
 Viewed   153 Time(s)

jpdfbookmarks-example.jpg


_________________
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 
Semme


Joined: 07 Aug 2011
Posts: 7775
Location: World_Hub

PostPosted: Thu 18 Dec 2014, 06:54    Post subject:    

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 <<<
Back to top
View user's profile Send private message 
slavvo67

Joined: 12 Oct 2012
Posts: 1434
Location: The other Mr. 305

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

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
Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 1398
Location: Japan

PostPosted: Thu 18 Dec 2014, 21:09    Post subject:  

slavvo67 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?
I'm afraid I have no idea what you mean Crying or Very sad
Quote:
This way, you could batch convert a whole directory.
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.
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 2 of 3 [33 Posts]   Goto page: Previous 1, 2, 3 Next
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.0558s ][ Queries: 14 (0.0051s) ][ GZIP on ]