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 Tue 19 Sep 2017, 20:27
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
jpeg pictures resizing in command line? [SOLVED]
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 2 [30 Posts]   Goto page: 1, 2 Next
Author Message
Argolance


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

PostPosted: Thu 03 Sep 2015, 07:07    Post subject:  jpeg pictures resizing in command line? [SOLVED]  

Bonjour,
Does any equivalent of "resizepng" exist for jpeg pictures resizing [EDIT] in command line? If possible, without installing imagemagick I would like to find something very simple, just to resize jpg files.

Coprdialement.

_________________


Last edited by Argolance on Thu 03 Sep 2015, 13:19; edited 3 times in total
Back to top
View user's profile Send private message Visit poster's website 
rcrsn51


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

PostPosted: Thu 03 Sep 2015, 07:55    Post subject:  

PeasyScale

If you just want a command-line tool, get MU's original scale2pic.
Back to top
View user's profile Send private message 
Argolance


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

PostPosted: Thu 03 Sep 2015, 09:25    Post subject:  

Hello,
Thanks rcrsn51!
I obviously thought of PeasyScale and tried to see if it was possible to use it in command line. I forgot to specify this "little" detail (corrected) in my question.
Strangly (I found it accidentally), not only the command:
Code:
resizepng file.jpg file.jpg 64 64 90
works fine, but also:
Code:
resizepng file.jpg file.png 64 64 90

... let me both resize/convert my original jpg file to png! Shocked
How can this be possible?
If this would be done without causing some issue, it would simplify my script a lot!

Anyway, where could I find this MU's scale2pic?

Cordialement.

_________________

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


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

PostPosted: Thu 03 Sep 2015, 10:48    Post subject:  

Argolance wrote:
Anyway, where could I find this MU's scale2pic?

There is a link to it on the PeasyScale page.
Back to top
View user's profile Send private message 
musher0


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

PostPosted: Thu 03 Sep 2015, 12:48    Post subject:  

Hello, Argolance.

With the netpbm package, you can construct a process like this:

jpegtopnm abc.jpg > abc.pnm
pamscale -pa -ra -me -ters abc.pnm > xyz.pnm
pnmtojpeg xyz.pnm > xyz.jpg

The pamscale utility provides "very fine tuning" of your picture.

This package is worth studying, since it does most of what imagemagick
does, without complications. You just use the utilities needed to get
your result.

I have provided last December a pet archive of netpbm-10.67.

The datafilehost link is still active. I hope this helps.

musher0

_________________
musher0
~~~~~~~~~~
« Un insensé sur le trône n'est qu'un singe sur le haut d'un toit. » / "A madman
on the throne is just a monkey on top of a roof." (Bernard de Clervaux)
Back to top
View user's profile Send private message 
Argolance


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

PostPosted: Thu 03 Sep 2015, 13:19    Post subject:  

Thank you to both of you. Smile

Cordialement.

_________________

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


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

PostPosted: Thu 03 Sep 2015, 13:42    Post subject:  

If you already have PeasyScale installed, you can use its command line tool
Code:
peasyscale.bin infile.jpg outfile.jpg SCALE

SCALE can either be a percent value like "50" or a size like "800x600"

To scale a batch of images, use
Code:
mkdir Scaled
for J in *.jpg; do peasyscale.bin $J Scaled/$J SCALE; done
Back to top
View user's profile Send private message 
Argolance


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

PostPosted: Thu 03 Sep 2015, 14:12    Post subject:  

Bonsoir,
Nobody seems to be amazed when I report that "resizepng", which is a little bin inside most of the Puppies (used by icon-switcher fro example). that makes the resizing fine, as well jpg to png than png to jpg!
I would like to understand this strange thing, though the thread is marked as SOLVED.

Cordialement.
Back to top
View user's profile Send private message Visit poster's website 
musher0


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

PostPosted: Thu 03 Sep 2015, 16:23    Post subject:  

Argolance wrote:
Bonsoir,
Nobody seems to be amazed when I report that "resizepng", which is a little bin inside most of the Puppies (used by icon-switcher fro example). that makes the resizing fine, as well jpg to png than png to jpg!
I would like to understand this strange thing, though the thread is marked as SOLVED.

Cordialement.


Hello, Argolance.

I am not amazed, and not even amused Wink

I am not sure about the meaning of your question, but here it goes:

I do not know exactly how the netpbm utilities work, but I know they do.

I do not know how pamscale shrinks a picture, which pixels are dropped
and why, for example. I can't say that I'm very interested in it either, I'm
not an engineer. I am the practical type, I am happy if / that a software
works, and rarely look beyond.

I do know that the netpbm package uses its own format (very close to
raw picture bytes, I believe, because the interim files are huge) to do
the processing. And when it is done you are asked to use the proper
conversion, to png or jpeg or bmp, etc.

Perhaps you can study the source code of some of the utilities to gain
some insight into how this is done. Or even e-mail the author?

BFN.

musher0

_________________
musher0
~~~~~~~~~~
« Un insensé sur le trône n'est qu'un singe sur le haut d'un toit. » / "A madman
on the throne is just a monkey on top of a roof." (Bernard de Clervaux)
Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 1348
Location: Japan

PostPosted: Fri 04 Sep 2015, 00:41    Post subject: Re: jpeg pictures resizing in command line? [SOLVED]  

Argolance wrote:
Does any equivalent of "resizepng" exist for jpeg pictures resizing [EDIT] in command line? If possible, without installing imagemagick I would like to find something very simple, just to resize jpg files.
You could try nconvert, a powerful command line tool. The GUI version XnConvert is also very nice, installs in /opt and can probably be used as a portable app.

As for resizepng: it's not "inside most of the Puppies", and without any documentation it is no wonder that it gets overlooked/ignored
Back to top
View user's profile Send private message 
Argolance


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

PostPosted: Fri 04 Sep 2015, 05:50    Post subject:  

Bonjour,
MochiMoppel wrote:
As for resizepng: it's not "inside most of the Puppies", and without any documentation it is no wonder that it gets overlooked/ignored

Code lines from the icon_switcher GUI by BK (Copyright Nov 2007 Barry Kauler www.puppylinux.com):
icon_switcher wrote:
[...]
ICONSETSGUI=""
for ONEDIR in `find /usr/local/lib/X11/themes/ -mindepth 1 -maxdepth 1 -type d | tr '\n' ' '`
do
ONENAME="`basename $ONEDIR`"
[ -f $ONEDIR/pc48.svg ] && rsvg-convert -w 32 -h 32 -o /tmp/pis-${ONENAME}-pc48.png $ONEDIR/pc48.svg # << rsvg-convert
[ -f $ONEDIR/pc48.png ] && cp -f $ONEDIR/pc48.png /tmp/pis-${ONENAME}-pc48.png && resizepng /tmp/pis-${ONENAME}-pc48.png /tmp/pis-${ONENAME}-pc48.png 32 32 90 # << resizepng
[ -f $ONEDIR/folder.svg ] && rsvg-convert -w 32 -h 32 -o /tmp/pis-${ONENAME}-folder.png $ONEDIR/folder.svg # << rsvg-convert
[ -f $ONEDIR/folder48.png ] && cp -f $ONEDIR/folder48.png /tmp/pis-${ONENAME}-folder.png && resizepng /tmp/pis-${ONENAME}-folder.png /tmp/pis-${ONENAME}-folder.png 32 32 90 # << resizepng
[...]

The bin 'resizepng' is present in all the puppies I used since 2007 inside /usr/bin as well as 'rsvg-convert' which converts svg files to png.
Quote:
You could try nconvert, a powerful command line tool. The GUI version XnConvert is also very nice, installs in /opt and can probably be used as a portable app.

I am an enthusiast of XnView/Xnconvert that are both available in the ToOpPy repository but not integrated to ToOpPy by default. 'resizepng' does the work I was expecting for and avoids me having to install additional programs to make my script run.
musher0 wrote:
I am not amazed, and not even amused Wink

I am not sure about the meaning of your question,
Shocked
Sorry, probably the way I tried to explain things in English. I admit I am not sure about the reason and the meaning of your own comment. Wink

The programs mentioned above are very functional/useful and it is a good thing for users who will read this thread to get an almost complete overview of them, including 'resizepng' and 'rsvg-convert'.
I thought it was interesting for users (and maybe developers) to report what 'resizepng' can do: apparently more than its name seems to talk about...
Please, just try and see by yourself.

Cordialement.

_________________

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


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

PostPosted: Fri 04 Sep 2015, 09:14    Post subject:  

I believe that resizepng is a version of MU's scale2pic. It uses some gtk functions that don't care about the type of the input file. So they will accept either JPGs or PNGs.

Code:
resizepng infile.jpg outfile.jpg 64 64 90

However, it may be that the output of resizepng is always PNG even if you name the file as JPG.

Check this with
Code:
file outfile.jpg
Back to top
View user's profile Send private message 
Argolance


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

PostPosted: Fri 04 Sep 2015, 09:37    Post subject:  

Hello,
Thanks for replying, rcrsn51.
You are absolutely right:
Code:
# file CURRENT.jpg
CURRENT.jpg: PNG image, 64 x 64, 8-bit/color RGB, non-interlaced

but, using a real jpg "CURRENT.jpg" 1024x768 file:
Code:
 # resizepng CURRENT.jpg CURRENT.png 200 200 90
# file  CURRENT.png
CURRENT.png: PNG image, 200 x 200, 8-bit/color RGB, non-interlaced

Argolance wrote:
I would like to understand this strange thing, though the thread is marked as SOLVED.
It is clear now and not so strange indeed! Wink
In my case this has an advantage over other bin: it makes both at the same time, resize and... "convert" to png.

Cordialement.

_________________

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


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

PostPosted: Fri 04 Sep 2015, 11:14    Post subject:  

Here is a version of resizepng that is more versatile. It can convert to/from JPEG, PNG or TIFF files. It will also accept other types like BMP or GIF as input. And it can resize by percent or image size.
Code:
image-changer infile.jpg outfile.png      #change image type
image-changer infile.jpg outfile.jpg 50     #reduce size to 50% of original
image-changer infile.jpg outfile.jpg 800x600     #reduce size to 800 by 600 pixels
image-changer infile.png outfile.tif 20     #do both operations at once

Image-changer can also perform some basic transformations.
Code:
image-changer infile outfile t1  #rotate +90 degrees
image-changer infile outfile t2  #rotate -90 degrees
image-changer infile outfile t3  #flip horizontally
image-changer infile outfile t4  #flip vertically
image-changer infile outfile t5  #rotate 180 degrees

Be aware that you CANNOT perform a resize and a transformation at the same time.

To process a batch of files, look at PeasyScale. It uses image-changer as its backend.

There is also a 64bit version of image-changer and the source code is available. All you have to do is ask.

-----------------
image_changer-1.2.pet
Description  Updated 2017-05-09
Rotate 180 transformation added
This is the 32bit version
pet

 Download 
Filename  image_changer-1.2.pet 
Filesize  3.23 KB 
Downloaded  27 Time(s) 

Last edited by rcrsn51 on Thu 29 Jun 2017, 15:54; edited 13 times in total
Back to top
View user's profile Send private message 
Argolance


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

PostPosted: Fri 04 Sep 2015, 11:18    Post subject:  

Great!
Adopted...

_________________

Back to top
View user's profile Send private message Visit poster's website 
Display posts from previous:   Sort by:   
Page 1 of 2 [30 Posts]   Goto page: 1, 2 Next
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Off-Topic Area » Programming
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.0570s ][ Queries: 13 (0.0057s) ][ GZIP on ]