I have a wiki/blog (Dokuwiki) that displays selected pictures from my main pictures store.
My pictures are stored in a <YEAR>/<MONTH>/<DAY> hierarchy and I have a script that searches for references to a specific date in the wiki and, if/when found, it copies the .jpg files to the appropriate place in the wiki.
This is OK with the wiki software running on my desktop machine (though the image size does make the images rather slow to load) but now I want to run the wiki on a hosting service and the size of the images is taking up too much disk space.
Is there any simple, automated way I can shrink the pictures? I don't want to have to specify a size for every one of them, I just want to shrink them to a 'reasonable' size.
I can fairly easily add a command (or two) to my script that does the copy, e.g. an ImageMagick 'convert' but how to set the amount of shrinkage?
On 05/01, Chris Green wrote:
Is there any simple, automated way I can shrink the pictures? I don't want to have to specify a size for every one of them, I just want to shrink them to a 'reasonable' size.
I can fairly easily add a command (or two) to my script that does the copy, e.g. an ImageMagick 'convert' but how to set the amount of shrinkage?
It depends what you're after.
You can resize by percentage:
convert in.jpg -resize 50% out.jpg
You can resize to a particular size but only if the image is larger than that already:
convert in.jpg -resize 800x600> out.jpg
Or you can resize so that the image has a certain area in pixels:
convert in.jpg -resize 480000@ out.jpg
This is a [handy link](http://www.imagemagick.org/Usage/resize/).
Steve
On Tue, 6 Jan 2015, Steve Engledow wrote:
On 05/01, Chris Green wrote:
Is there any simple, automated way I can shrink the pictures? I don't want to have to specify a size for every one of them, I just want to shrink them to a 'reasonable' size.
I can fairly easily add a command (or two) to my script that does the copy, e.g. an ImageMagick 'convert' but how to set the amount of shrinkage?
It depends what you're after.
You can resize by percentage:
convert in.jpg -resize 50% out.jpg
You can resize to a particular size but only if the image is larger than that already:
convert in.jpg -resize 800x600> out.jpg
Or you can resize so that the image has a certain area in pixels:
convert in.jpg -resize 480000@ out.jpg
This is a [handy link](http://www.imagemagick.org/Usage/resize/).
Steve
Imagemagick I have found excellent as the quickest for batch resizing and watermark. I don't use convert though - I use mogrify. Perhaps convert does them as pixel size... haven't got the book handy to check.
# batch resize mogrify -resize 50% *.jpg
#date watermark mogrify -font /usr/share/fonts/truetype/msttcorefonts/Arial.ttf \ -pointsize 20 -gravity southeast \ -fill black -annotate +10+10 '04May2014' \ -fill white -annotate +11+11 '04May2014' \ *.jpg
james
On Tue, 6 Jan 2015, Steve Engledow wrote:
On 06/01, James Freer wrote:
I don't use convert though - I use mogrify. Perhaps convert does them as pixel size... haven't got the book handy to check.
Mogrify modifies the image directly; convert makes a copy and modifies that :)
Steve
Similar and different. 'Imagemagick Tricks' by Salehi recommends modifying with mogrify and creating with convert. I keep original pics in a directory and copy to another to be modified, that way one always has an original to return to. In the book it uses convert to create logos on shapes and such like. Convert is a creation tool which is not really the case with pics. It's a while since I explored it's use.
james
On Tue, Jan 06, 2015 at 01:48:23PM +0000, James Freer wrote:
On Tue, 6 Jan 2015, Steve Engledow wrote:
On 05/01, Chris Green wrote:
Is there any simple, automated way I can shrink the pictures? I don't want to have to specify a size for every one of them, I just want to shrink them to a 'reasonable' size.
I can fairly easily add a command (or two) to my script that does the copy, e.g. an ImageMagick 'convert' but how to set the amount of shrinkage?
It depends what you're after.
You can resize by percentage:
convert in.jpg -resize 50% out.jpg
You can resize to a particular size but only if the image is larger than that already:
convert in.jpg -resize 800x600> out.jpg
Or you can resize so that the image has a certain area in pixels:
convert in.jpg -resize 480000@ out.jpg
This is a [handy link](http://www.imagemagick.org/Usage/resize/).
Steve
Imagemagick I have found excellent as the quickest for batch resizing and watermark. I don't use convert though - I use mogrify. Perhaps convert does them as pixel size... haven't got the book handy to check.
# batch resize mogrify -resize 50% *.jpg
#date watermark mogrify -font /usr/share/fonts/truetype/msttcorefonts/Arial.ttf \ -pointsize 20 -gravity southeast \ -fill black -annotate +10+10 '04May2014' \ -fill white -annotate +11+11 '04May2014' \ *.jpg
Part of the question was really about what size I should resize them to!
OK, so Imagemagick seems to be the tool of choice. How do I decide what size to make the JPGs? I don't want to have to individually decide for each picture, most will start as 3264x2448 but I can't guarantee that they're all that size. So, say I decided that a maximum dimension of 1024 pixels made sense how do I automate converting a random collection of JPG images to <=1024 in either direction?
On Tue, 6 Jan 2015, Chris Green wrote:
On Tue, Jan 06, 2015 at 01:48:23PM +0000, James Freer wrote:
On Tue, 6 Jan 2015, Steve Engledow wrote:
On 05/01, Chris Green wrote:
Is there any simple, automated way I can shrink the pictures? I don't want to have to specify a size for every one of them, I just want to shrink them to a 'reasonable' size.
I can fairly easily add a command (or two) to my script that does the copy, e.g. an ImageMagick 'convert' but how to set the amount of shrinkage?
It depends what you're after.
You can resize by percentage:
convert in.jpg -resize 50% out.jpg
You can resize to a particular size but only if the image is larger than that already:
convert in.jpg -resize 800x600> out.jpg
Or you can resize so that the image has a certain area in pixels:
convert in.jpg -resize 480000@ out.jpg
This is a [handy link](http://www.imagemagick.org/Usage/resize/).
Steve
Imagemagick I have found excellent as the quickest for batch resizing and watermark. I don't use convert though - I use mogrify. Perhaps convert does them as pixel size... haven't got the book handy to check.
# batch resize mogrify -resize 50% *.jpg
#date watermark mogrify -font /usr/share/fonts/truetype/msttcorefonts/Arial.ttf \ -pointsize 20 -gravity southeast \ -fill black -annotate +10+10 '04May2014' \ -fill white -annotate +11+11 '04May2014' \ *.jpg
Part of the question was really about what size I should resize them to!
OK, so Imagemagick seems to be the tool of choice. How do I decide what size to make the JPGs? I don't want to have to individually decide for each picture, most will start as 3264x2448 but I can't guarantee that they're all that size. So, say I decided that a maximum dimension of 1024 pixels made sense how do I automate converting a random collection of JPG images to <=1024 in either direction?
-- Chris Green
At a quick glance you need to use the -resize -filter and -sample options and that'll give you what you require to retain aspect ratio. Join the IM forum they are a helpful bunch. IM is a very powerful app and takes some learning.
My pics are 1600 x 800 and I mogrify to 700 x 525 for forums... 1024 x 768 for my desktop dog pics. I wanted to do bulk resizing and watermarking quickly and that was as far as I went.
james
OK, so Imagemagick seems to be the tool of choice. How do I decide what size to make the JPGs? I don't want to have to individually decide for each picture, most will start as 3264x2448 but I can't guarantee that they're all that size. So, say I decided that a maximum dimension of 1024 pixels made sense how do I automate converting a random collection of JPG images to <=1024 in either direction?
So, the -resize option actually defines a bounding box.
I.e. if you use:
convert in.jpg -resize 1024x1024 out.jpg
out.jpg will be an image that will be at most 1024x1024, but could be 768x1024 or 1024x768.
If you wanted to make sure that you only resize things that are already bigger than 1024x1024, you'd do:
convert in.jpg -resize 1024x1024> out.jpg
Thanks,
On Tue, Jan 06, 2015 at 06:04:17PM +0000, Brett Parker wrote:
OK, so Imagemagick seems to be the tool of choice. How do I decide what size to make the JPGs? I don't want to have to individually decide for each picture, most will start as 3264x2448 but I can't guarantee that they're all that size. So, say I decided that a maximum dimension of 1024 pixels made sense how do I automate converting a random collection of JPG images to <=1024 in either direction?
So, the -resize option actually defines a bounding box.
I.e. if you use:
convert in.jpg -resize 1024x1024 out.jpg
out.jpg will be an image that will be at most 1024x1024, but could be 768x1024 or 1024x768.
If you wanted to make sure that you only resize things that are already bigger than 1024x1024, you'd do:
convert in.jpg -resize 1024x1024> out.jpg
Brilliant, that sounds just about exactly what I need, thanks.