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 17 Apr 2014, 10:19
All times are UTC - 4
 Forum index » Advanced Topics » Additional Software (PETs, n' stuff) » Graphics
Convert png picture to jpg in command line [SOLVED]
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [12 Posts]  
Author Message
Argolance


Joined: 06 Jan 2008
Posts: 1774
Location: PORT-BRILLET (Mayenne - France)

PostPosted: Tue 14 Aug 2012, 09:33    Post subject:  Convert png picture to jpg in command line [SOLVED]  

Hello,
Does any very small and autonomous script exist, already present (or not!) on Puppy (as "resizepng" for example!) that would convert png pictures to jpg (something like "png2jpg")? Where could I find this?

Cordialement.

_________________


Last edited by Argolance on Wed 15 Aug 2012, 12:38; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website 
rcrsn51


Joined: 05 Sep 2006
Posts: 8550
Location: Stratford, Ontario

PostPosted: Tue 14 Aug 2012, 09:51    Post subject:  

Code:
pngtopnm xxx.png | pnmtojpeg > xxx.jpg

Or as a script named "png2jpg":
Code:
#!/bin/sh
pngtopnm $1 | pnmtojpeg > ${1%.*}.jpg

Or if your filenames may contain spaces:
Code:
#!/bin/sh
pngtopnm "$1" | pnmtojpeg > "${1%.*}.jpg"
Back to top
View user's profile Send private message 
Argolance


Joined: 06 Jan 2008
Posts: 1774
Location: PORT-BRILLET (Mayenne - France)

PostPosted: Tue 14 Aug 2012, 12:44    Post subject:  

Hello rcrsn51,
Thank you! Very Happy
I know this is not the place to ask this question but:
I didn't succeed in making several commands one after the other with scrot...
Quote:
Usage : scrot [OPTIONS]... [FILE]
Where FILE is the target file for the screenshot.
If FILE is not specified, a date-stamped file will be dropped in the
current directory.
See man scrot for more details
-h, --help display this help and exit
-v, --version output version information and exit
-b, --border When selecting a window, grab wm border too
-c, --count show a countdown before taking the shot
-d, --delay NUM wait NUM seconds before taking a shot
-e, --exec APP run APP on the resulting screenshot
-q, --quality NUM Image quality (1-100) high value means
high size, low compression. Default: 75.
For lossless compression formats, like png,
low quality means high compression.
-m, --multidisp For multiple heads, grab shot from each
and join them together.
-s, --select interactively choose a window or rectnagle
with the mouse
-t, --thumb NUM generate thumbnail too. NUM is the percentage
of the original size for the thumbnail to be,
or the geometry in percent, e.g. 50x60 or 80x20.

SPECIAL STRINGS
Both the --exec and filename parameters can take format specifiers
that are expanded by scrot when encountered.
There are two types of format specifier. Characters preceded by a '%'
are interpretted by strftime(2). See man strftime for examples.
These options may be used to refer to the current date and time.
The second kind are internal to scrot and are prefixed by '$'
The following specifiers are recognised:
$f image path/filename (ignored when used in the filename)
$m thumbnail path/filename
$n image name (ignored when used in the filename)
$s image size (bytes) (ignored when used in the filename)
$p image pixel size
$w image width
$h image height
$t image format
$$ prints a literal '$'
\n prints a newline (ignored when used in the filename)
Example:
scrot '%Y-%m-%d_$wx$h_scrot.png' -e 'mv $f ~/images/shots/'
Creates a file called something like 2000-10-30_2560x1024_scrot.png
and moves it to your images directory.

How could this be done? i. e. get a picture, give it defined height and width in pixels then save it in a directory as jpg file, all in the same command line...
Any idea?
Thank you!

Cordialement!

_________________

Back to top
View user's profile Send private message Visit poster's website 
Karl Godt


Joined: 20 Jun 2010
Posts: 3860
Location: Kiel,Germany

PostPosted: Tue 14 Aug 2012, 13:33    Post subject:  

scrot is patched by ubuntu . At least one option is not in the original source code iirc.
Back to top
View user's profile Send private message Visit poster's website 
Jasper


Joined: 25 Apr 2010
Posts: 1032
Location: England

PostPosted: Tue 14 Aug 2012, 13:55    Post subject:  

Hi Argolance,

If you haven't seen PupSnap find any post by radky and click on his PupMates, signature and scroll down to PupSnap 1.8. It's superb and may be of huge interest to you.

My regards
Back to top
View user's profile Send private message 
rcrsn51


Joined: 05 Sep 2006
Posts: 8550
Location: Stratford, Ontario

PostPosted: Tue 14 Aug 2012, 16:27    Post subject:  

Argolance wrote:
How could this be done? i. e. get a picture, give it defined height and width in pixels then save it in a directory as jpg file, all in the same command line...

Try this
Code:
#!/bin/sh
pngtopnm "$1" | pnmscale -width $2 -height $3 | pnmtojpeg > "${1%.*}.jpg"
Back to top
View user's profile Send private message 
Argolance


Joined: 06 Jan 2008
Posts: 1774
Location: PORT-BRILLET (Mayenne - France)

PostPosted: Wed 15 Aug 2012, 05:29    Post subject:  

Hello,
@Jasper
Quote:
If you haven't seen PupSnap find any post by radky and click on his PupMates, signature and scroll down to PupSnap 1.8. It's superb and may be of huge interest to you.
... Sorry but it is not what I am looking for: I made a very similar script for Toutou LINUX (French version of Puppy) and posted it in the Forum => Easyshot

I would like a single scrot command line working quietly inside an other script.Till now, I saved the "scrot" picture somewhere then, using several different scripts, reduced, converted, renamed and moved this image to a specific directory (and this was first the reason of this thread!). But, looking at the help file of "scrot" (please see above), it seems possible to do this at one time, directly with the "scrot" options but I guess I don't know how to build this command for scrot to execute all the options inside a single line...
I think this question should/could be solved and very useful...

@rcrsn51
This is interesting because scrot can make pictures directly in pnm format. Your command line suits me and it will be enough for me!
Thank you!
Just a last question: "$1" => picture name? $2 and $3 => width/height in pixels?

Cordialement.

_________________

Back to top
View user's profile Send private message Visit poster's website 
stu91


Joined: 06 Aug 2012
Posts: 144
Location: England. Dpup. Dell Inspiron 1501

PostPosted: Wed 15 Aug 2012, 06:53    Post subject:  

Hi Argolance,
I dont think you can directly specify resolution for scrots main screen capture - you need to take the main capture then scale it to size with the -t thumb nail option - then remove rm $f main capture and move thunbnail mv $m to main file name $f.
try:

Code:
scrot -t 640x400 '/root/test.jpg' -e 'rm $f && mv $m $f'


or

Code:
scrot -t 50%  '/root/test.jpg' -e 'rm $f && mv $m $f'
Back to top
View user's profile Send private message 
Argolance


Joined: 06 Jan 2008
Posts: 1774
Location: PORT-BRILLET (Mayenne - France)

PostPosted: Wed 15 Aug 2012, 12:37    Post subject:  

Hello stu91,
This looks (a little bit!) like what I did, using pnm commands:
Code:
   scrot 'theme_shot_tmp.pnm' -e 'mv $f /tmp/'
   pnmscale '/tmp/theme_shot_tmp.pnm' -width 600 -height 375 | pnmtojpeg  > '/tmp/theme_shot_tmp.jpg'
   mv -f /tmp/theme_shot_tmp.jpg /root/.jwm/themes/themes_pictures/"${THEME_NAME_}_perso.jpg"

Thank you very much to all of you!
This Forum is "fantastic"!

Cordialement.

_________________

Back to top
View user's profile Send private message Visit poster's website 
MU


Joined: 24 Aug 2005
Posts: 13642
Location: Karlsruhe, Germany

PostPosted: Mon 20 Aug 2012, 18:42    Post subject:  

scale2pic:
http://murga-linux.com/puppy/viewtopic.php?t=29184

Mark

_________________
my recommended links
Back to top
View user's profile Send private message Visit poster's website 
rcrsn51


Joined: 05 Sep 2006
Posts: 8550
Location: Stratford, Ontario

PostPosted: Tue 21 Aug 2012, 11:27    Post subject:  

A GUI version of scale2pic is here.
Back to top
View user's profile Send private message 
Argolance


Joined: 06 Jan 2008
Posts: 1774
Location: PORT-BRILLET (Mayenne - France)

PostPosted: Tue 21 Aug 2012, 13:36    Post subject:  

Thanks...
_________________

Back to top
View user's profile Send private message Visit poster's website 
Display posts from previous:   Sort by:   
Page 1 of 1 [12 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Advanced Topics » Additional Software (PETs, n' stuff) » Graphics
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.0673s ][ Queries: 12 (0.0035s) ][ GZIP on ]