Convert png picture to jpg in command line [SOLVED]
- Argolance
- Posts: 3767
- Joined: Sun 06 Jan 2008, 22:57
- Location: PORT-BRILLET (Mayenne - France)
- Contact:
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.
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, 16:38, edited 1 time in total.
Code: Select all
pngtopnm xxx.png | pnmtojpeg > xxx.jpg
Code: Select all
#!/bin/sh
pngtopnm $1 | pnmtojpeg > ${1%.*}.jpg
Code: Select all
#!/bin/sh
pngtopnm "$1" | pnmtojpeg > "${1%.*}.jpg"
- Argolance
- Posts: 3767
- Joined: Sun 06 Jan 2008, 22:57
- Location: PORT-BRILLET (Mayenne - France)
- Contact:
Hello rcrsn51,
Thank you!
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...
Any idea?
Thank you!
Cordialement!
Thank you!
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...
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...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.
Any idea?
Thank you!
Cordialement!
Try thisArgolance 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...
Code: Select all
#!/bin/sh
pngtopnm "$1" | pnmscale -width $2 -height $3 | pnmtojpeg > "${1%.*}.jpg"
- Argolance
- Posts: 3767
- Joined: Sun 06 Jan 2008, 22:57
- Location: PORT-BRILLET (Mayenne - France)
- Contact:
Hello,
@Jasper
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.
@Jasper
... 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=> EasyshotIf 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.
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.
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:
or
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: Select all
scrot -t 640x400 '/root/test.jpg' -e 'rm $f && mv $m $f'
Code: Select all
scrot -t 50% '/root/test.jpg' -e 'rm $f && mv $m $f'
- Argolance
- Posts: 3767
- Joined: Sun 06 Jan 2008, 22:57
- Location: PORT-BRILLET (Mayenne - France)
- Contact:
Hello stu91,
This looks (a little bit!) like what I did, using pnm commands:
Thank you very much to all of you!
This Forum is "fantastic"!
Cordialement.
This looks (a little bit!) like what I did, using pnm commands:
Code: Select all
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"
This Forum is "fantastic"!
Cordialement.