Macro for ImageResize

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Macro for ImageResize

Frank Walter
Hello,

is there a macro to resize all images in one folder to a special value and
save them?

I need a tool on my Ubuntu-server (without GUI) to adjust the size of all
images in one folder to maximum 800x600 pixels (only if they are bigger),
not loosing proportions.

Thank you for hints,

regards, franc
Reply | Threaded
Open this post in threaded view
|

Re: Macro for ImageResize

Michael Doube
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Franc,

> I need a tool on my Ubuntu-server (without GUI) to adjust the size of
> all images in one folder to maximum 800x600 pixels (only if they are
> bigger), not loosing proportions.

Imagemagick does this, and you may already have it on your Ubuntu box.
http://www.imagemagick.org/script/convert.php

Michael
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJM5lYbAAoJED4GNP0caPn9pyAH/iCoVeVYBF8avmceTWdzQ/Ui
1EySVtwVUkZXUN0aWJmQAO6KwQBBybd8MssLANfeQRNhbC9DXH5tXvZYbAntoyXw
6/f3PCdKm+D3GpHCA9vBVHCNs7LfrEy+UOfdp/B9M7m6Agck4QhOfxd43BoV9vxl
sjJq5S8zOuhiBgAzLr7dSfvR3/LbJZwmTyJWpZk0US8rn1s7z6or+1hiX1MikFAI
OqHQSnNmXIYuucDZRvgof8+8hRwN4YlpQMbSXxymSTP7IB4RWQfToU88ylmSgkn7
7ucfGPSPASYT3jM140aDZbRdx8+1/SyYatpDI/GMfYI0OAoEI4OFoSP/OCzIW88=
=O8ln
-----END PGP SIGNATURE-----
Reply | Threaded
Open this post in threaded view
|

AW: Macro for ImageResize

Frank Walter
Michael,

thank you very much. This works very easy, e.g.:

convert * -resize '800x600' output.jpg

or

convert * -resize '800x600^' output.jpg

if I want to keep the bigger size as minimum. Only question (off topic
because imagemagick):

how can I keep the original names?

Thank you.

Regards, franc





> -----Original Message-----
> Von: ImageJ Interest Group [mailto:[hidden email]] Im Auftrag von
> Michael Doube
> Gesendet: Freitag, 19. November 2010 11:49
> An: [hidden email]
> Betreff: Re: Macro for ImageResize
>
>
> Franc,
>
> > I need a tool on my Ubuntu-server (without GUI) to adjust the size of
> > all images in one folder to maximum 800x600 pixels (only if they are
> > bigger), not loosing proportions.
>
> Imagemagick does this, and you may already have it on your Ubuntu box.
> http://www.imagemagick.org/script/convert.php
>
> Michael
Reply | Threaded
Open this post in threaded view
|

Re: Macro for ImageResize

dscho
In reply to this post by Michael Doube
Hi,

On Fri, 19 Nov 2010, Michael Doube wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> > I need a tool on my Ubuntu-server (without GUI) to adjust the size of
> > all images in one folder to maximum 800x600 pixels (only if they are
> > bigger), not loosing proportions.
>
> Imagemagick does this, and you may already have it on your Ubuntu box.
> http://www.imagemagick.org/script/convert.php

Alternatively, you could write a very, very simple macro to resize the
current image, and use it with Process>Batch>Macro...

Ciao,
Johannes
Reply | Threaded
Open this post in threaded view
|

Re: Macro for ImageResize

Carnë Draug
In reply to this post by Frank Walter
On 19 November 2010 12:16, Frank Walter <[hidden email]> wrote:

> Michael,
>
> thank you very much. This works very easy, e.g.:
>
> convert * -resize '800x600' output.jpg
>
> or
>
> convert * -resize '800x600^' output.jpg
>
> if I want to keep the bigger size as minimum. Only question (off topic
> because imagemagick):
>
> how can I keep the original names?
>
> Thank you.
>
> Regards, franc

Hi Frank,

I wrote some time ago a perl script to do exactly that using image
magick. I adjusted them for your needs. One of them adjusts the size
to a certain ratio while the other to a specific value for width and
height. They take as arguments a list of directories and save the
images with exactly the same name. You'll need the package perlmagick
installed on ubuntu.

adjust by ratio   http://pastebin.com/6P61bQyR
adjust by size  http://pastebin.com/DAXmJyZ5

Carnë
Reply | Threaded
Open this post in threaded view
|

Re: Macro for ImageResize

Jim Passmore
In reply to this post by Frank Walter
Frank,

Replace 'convert' with the ImageMagick 'mogrify' command.  I think it would
then be
mogrify -resize 800x600^ *.jpg

Caution:  BACKUP your data first!!!!  The mogrify command overwrites the
original file with the changed file!

Also, as is frequently pointed out on this list, think twice about the jpeg
format.  Every time you save a jpeg, you degrade the quality, so if you're
going to to any later processing, measurement, etc., you may be hurting the
results.  (If this is the last operation on these images and you need the
smaller file size, then jpeg is probably acceptable.)

Therefore, another (better?) command producing a second file name might use
the mogrify -format option.  I think this is the only time mogrify produces
a new file instead of overwriting the first.
mogrify -resize 800x600^ -format tif *.jpg

If you're already adept with ImageJ, Johannes' suggestion might be easier.

Regards,

*Jim Passmore*
Research Associate
Sealed Air Corporation
[hidden email]
864-433-2927 voice
864-433-2205 fax


On Fri, Nov 19, 2010 at 7:16 AM, Frank Walter <[hidden email]> wrote:

> Michael,
>
> thank you very much. This works very easy, e.g.:
>
> convert * -resize '800x600' output.jpg
>
> or
>
> convert * -resize '800x600^' output.jpg
>
> if I want to keep the bigger size as minimum. Only question (off topic
> because imagemagick):
>
> how can I keep the original names?
>
> Thank you.
>
> Regards, franc
>
>
>
>
>
> > -----Original Message-----
> > Von: ImageJ Interest Group [mailto:[hidden email]] Im Auftrag von
> > Michael Doube
> > Gesendet: Freitag, 19. November 2010 11:49
> > An: [hidden email]
> > Betreff: Re: Macro for ImageResize
> >
> >
> > Franc,
> >
> > > I need a tool on my Ubuntu-server (without GUI) to adjust the size of
> > > all images in one folder to maximum 800x600 pixels (only if they are
> > > bigger), not loosing proportions.
> >
> > Imagemagick does this, and you may already have it on your Ubuntu box.
> > http://www.imagemagick.org/script/convert.php
> >
> > Michael
>
Reply | Threaded
Open this post in threaded view
|

AW: Macro for ImageResize

Frank Walter
In reply to this post by Carnë Draug
Thank you very much, this works well!

Regards, franc



> -----Ursprüngliche Nachricht-----
> Von: ImageJ Interest Group [mailto:[hidden email]] Im Auftrag von
> Carnë Draug
> Gesendet: Freitag, 19. November 2010 15:02
> An: [hidden email]
> Betreff: Re: Macro for ImageResize
>
> On 19 November 2010 12:16, Frank Walter <[hidden email]> wrote:
> > Michael,
> >
> > thank you very much. This works very easy, e.g.:
> >
> > convert * -resize '800x600' output.jpg
> >
> > or
> >
> > convert * -resize '800x600^' output.jpg
> >
> > if I want to keep the bigger size as minimum. Only question (off topic
> > because imagemagick):
> >
> > how can I keep the original names?
> >
> > Thank you.
> >
> > Regards, franc
>
> Hi Frank,
>
> I wrote some time ago a perl script to do exactly that using image
> magick. I adjusted them for your needs. One of them adjusts the size
> to a certain ratio while the other to a specific value for width and
> height. They take as arguments a list of directories and save the
> images with exactly the same name. You'll need the package perlmagick
> installed on ubuntu.
>
> adjust by ratio   http://pastebin.com/6P61bQyR
> adjust by size  http://pastebin.com/DAXmJyZ5
>
> Carnë
Reply | Threaded
Open this post in threaded view
|

Re: Macro for ImageResize

Carnë Draug
I forgot to mention one thing about the scripts. They skip every file
whose extension does not end in jpg (this is to allow files other than
images on the directory, such as log files). This can be easily
changed to your needs. To allow both jpg, tiff, tif and png
extensions, replace the line

   if ($file =~ m/jpg$/i){

by the line

   if ($file =~ m/(jpg|tif|tiff|png)$/i){

That is, basically just enter the extensions in a parethensis separated by a |

On the subject of losing the image quality every time you save a JPEG
image, you can set its quality as in the following example (the
following example only applies for JPEG/MIFF/PNG images).

$image    -> Write(filename    => $path,
                   quality     => 100,
                   );

Carnë
Reply | Threaded
Open this post in threaded view
|

AW: Macro for ImageResize

Frank Walter
In reply to this post by Jim Passmore
Thank you very much, Jim.

Mogrify is maybe exactly the solution I was looking for.
So this and the solution of Carné are the things I will use.

Thank you so much for this fast and efficient help here, everybody!

Regards, kindsomes,

frank




> -----Ursprüngliche Nachricht-----
> Von: ImageJ Interest Group [mailto:[hidden email]] Im Auftrag von
> James Passmore
> Gesendet: Freitag, 19. November 2010 15:10
> An: [hidden email]
> Betreff: Re: Macro for ImageResize
>
> Frank,
>
> Replace 'convert' with the ImageMagick 'mogrify' command.  I think it
would
> then be
> mogrify -resize 800x600^ *.jpg
>
> Caution:  BACKUP your data first!!!!  The mogrify command overwrites the
> original file with the changed file!
>
> Also, as is frequently pointed out on this list, think twice about the
jpeg
> format.  Every time you save a jpeg, you degrade the quality, so if you're
> going to to any later processing, measurement, etc., you may be hurting
the
> results.  (If this is the last operation on these images and you need the
> smaller file size, then jpeg is probably acceptable.)
>
> Therefore, another (better?) command producing a second file name might
use
> the mogrify -format option.  I think this is the only time mogrify
produces

> a new file instead of overwriting the first.
> mogrify -resize 800x600^ -format tif *.jpg
>
> If you're already adept with ImageJ, Johannes' suggestion might be easier.
>
> Regards,
>
> *Jim Passmore*
> Research Associate
> Sealed Air Corporation
> [hidden email]
> 864-433-2927 voice
> 864-433-2205 fax
>
>
> On Fri, Nov 19, 2010 at 7:16 AM, Frank Walter <[hidden email]> wrote:
>
> > Michael,
> >
> > thank you very much. This works very easy, e.g.:
> >
> > convert * -resize '800x600' output.jpg
> >
> > or
> >
> > convert * -resize '800x600^' output.jpg
> >
> > if I want to keep the bigger size as minimum. Only question (off topic
> > because imagemagick):
> >
> > how can I keep the original names?
> >
> > Thank you.
> >
> > Regards, franc
> >
> >
> >
> >
> >
> > > -----Original Message-----
> > > Von: ImageJ Interest Group [mailto:[hidden email]] Im Auftrag von
> > > Michael Doube
> > > Gesendet: Freitag, 19. November 2010 11:49
> > > An: [hidden email]
> > > Betreff: Re: Macro for ImageResize
> > >
> > >
> > > Franc,
> > >
> > > > I need a tool on my Ubuntu-server (without GUI) to adjust the size
of
> > > > all images in one folder to maximum 800x600 pixels (only if they are
> > > > bigger), not loosing proportions.
> > >
> > > Imagemagick does this, and you may already have it on your Ubuntu box.
> > > http://www.imagemagick.org/script/convert.php
> > >
> > > Michael
> >