Forums / Setup & design / Image filters
Jérôme Vieilledent
Thursday 30 August 2007 3:23:29 am
Hello,
I would like to add an alias "thumbnail" to images uploaded. This thumbnail must be square (like 100*100). The idea is to scaledown first the image uploaded and then cropping it to obtain a square (the inverse is also possible : crop and then scaledown).
The problem is that I must match the shorter side to have a clean square, or at least I have to know the size of the original image to then use it to crop with the right side size.
Do you know if something like that is possible ? Or maybe it's possible to define a new imageFilter...
Thanks
Georg Franz
Thursday 30 August 2007 3:40:14 am
Hi Jérôme,
try this in your image.ini.append
[AliasSettings] ...AliasList[]=smallpic
[ImageMagick] ... Filters[]=thumb=-resize 'x%1' -resize '%1x<' -resize 50% Filters[]=centerimg=-gravity center -crop %1x%2+0+0 +repageFilters[]=strip=-strip
[smallpic] Reference= Filters[] Filters[]=thumb=200 Filters[]=centerimg=100;100Filters[]=strip=
It's not perfect, but it works: -) First you scale the image twice big as you want to have it in the final result (in that case 200 px) -) Then you resize it to 50%-) Then you crop it
The last "strip" strips off exif infos from the image.
If you have "normal" pictures it should work.
HTH
Best wishes,Georg.
Best wishes, Georg. -- http://www.schicksal.com Horoskop website which uses eZ Publish since 2004
Thursday 30 August 2007 5:34:42 am
Hello Georg and thanks for your reply :-)
I've never used ImageMagick, and so I don't really understand the filters you describe (Is there somewhere an explanation about how to use these settings ?), I don't understand what does mean %1,...
Is it possible to do such a thing with standard GD2 ?In PHP manual coding, what I usually do is first measuring the image, take the smallest value and crop with that value, and then I resize. The thing is that here I can't know the size of the image by advance... So I can't crop precisely.
Is there an issue for that ?
And about ImageMagick, do I have to change something in the image.ini.append.php to use it ? I think I must have ImageMagick installed on my computer, ain't I ?
Thanks for your help
Thursday 30 August 2007 6:16:28 am
install and use ImageMagick, it's better than GD2.
Ignore the %1 in the filter settings, it's just a placeholder for the first value from the image ini block. (%2 for the 2nd and so on.)
Example image.ini for IM: [ImageMagick] IsEnabled=true ExecutablePath= Executable=convert ExecutableWin32=convertExecutableUnix=/usr/bin/convert
More infos about crop + thumbnails from IM: http://www.imagemagick.org/Usage/crop/http://www.imagemagick.org/Usage/thumbnails/
Saturday 01 September 2007 7:13:37 am
Thank you, I will try :-)
Stéphane Bullier
Sunday 02 September 2007 11:04:14 pm
Hi,
You can find info here : http://ez.no/download/ez_publish/changelogs/ez_publish_3_3/new_image_system
Stéphane
meinhard benn
Saturday 08 August 2009 10:11:24 am
thanks, georg!
to increase quality of my thumbnails i added a quality setting and a sharpening filter. from my image.ini.append.php:
[ImageMagick] Filters[]=thumb=-resize 'x%1' -resize '%1x<' -resize 50% -quality 90 Filters[]=centerimg=-gravity center -crop %1x%2+0+0 +repageFilters[]=sharpen=-sharpen 0.5
[gallerythumbnail] Reference= Filters[] Filters[]=thumb=200 Filters[]=centerimg=100;100Filters[]=sharpen=
cheers, meinhard.
http://goozee.benn.org/ - Google Co-op for eZ sites