Reputation: 2711
We recently decided to redesign our old app which used 150x150 thumbnails. New thumbs are of size 250x250. Now i have to change all thumbs that were created by previous entries.
The function used for creating new thumbnails is php's imagecopyresampled
.
Do you suggest resizing all the old thumbnails using php or any other more native os language / software that would resize them faster locally? (Software has to support copyresampled
function or something with similar result).
Also, the job itself is a little complicated since there are some folders that has to be excluded when iterating trough the files.
level 1: company folder
level 2: company property folder, company products folder
level 3: there are images that have to be resized inside company property folder.
company 1
company 2
company 3
----company 3 property
--------image1.jpg (original size)
--------image1_thumb.jpg (old 150 thumb)
--------image2.jpg
--------image2_thumb.jpg
----company 3 products (folder also includes images but they should not be resized)
I could also use the other way and look for image names/paths in property database
, but that would probably be slower than just iterating trough folders. What do you think?
Upvotes: 0
Views: 87
Reputation:
It look like one time job? if so you use ImageMagick's convert
utility to resize all thumb images at one hit:
$ convert -resize '250x250' image1.jpg image1_thumb.jpg
You can loop throght the images using proper pattern:
$ for i in $(find . -regex '.*image[0-9]+\.jpg'); do echo $i ; done
./image2.jpg
./image1.jpg
./image4.jpg
./image3.jpg
$
and convert them using the previous command:
for i in $(find . -regex '.*image[0-9]+\.jpg'); do
convert -resize '250x250' $i $(echo $i | sed 's/.jpg/_thumb.jpg/g');
done
preview:
$ ls
image1.jpg image2.jpg image3.jpg image4.jpg
$ for i in $(find . -regex '.*image[0-9]+\.jpg'); do echo $i ; done
./image2.jpg
./image1.jpg
./image4.jpg
./image3.jpg
$ for i in $(find . -regex '.*image[0-9]+\.jpg'); do
> convert -resize '250x250' $i $(echo $i | sed 's/.jpg/_thumb.jpg/g');
> done
$ ls
image1.jpg image1_thumb.jpg image2.jpg image2_thumb.jpg image3.jpg image3_thumb.jpg image4.jpg image4_thumb.jpg
$
let it runs until all images are converted.
Upvotes: 1