Image filters

Author Message

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 +repage
Filters[]=strip=-strip

[smallpic]
Reference=
Filters[]
Filters[]=thumb=200
Filters[]=centerimg=100;100
Filters[]=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

Jérôme Vieilledent

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

Georg Franz

Thursday 30 August 2007 6:16:28 am

Hi Jérôme,

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=convert
ExecutableUnix=/usr/bin/convert

More infos about crop + thumbnails from IM:
http://www.imagemagick.org/Usage/crop/
http://www.imagemagick.org/Usage/thumbnails/

Best wishes,
Georg.

--
http://www.schicksal.com Horoskop website which uses eZ Publish since 2004

Jérôme Vieilledent

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 +repage
Filters[]=sharpen=-sharpen 0.5

[gallerythumbnail]
Reference=
Filters[]
Filters[]=thumb=200
Filters[]=centerimg=100;100
Filters[]=sharpen=

cheers, meinhard.

http://goozee.benn.org/ - Google Co-op for eZ sites

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 18 2025 18:38:26
Script start
Timing: Jan 18 2025 18:38:26
Module start 'layout'
Timing: Jan 18 2025 18:38:26
Module start 'content'
Timing: Jan 18 2025 18:38:26
Module end 'content'
Timing: Jan 18 2025 18:38:26
Script end

Main resources:

Total runtime0.0159 sec
Peak memory usage2,048.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0064 588.9219152.6094
Module start 'layout' 0.00640.0024 741.531339.4141
Module start 'content' 0.00880.0050 780.945397.2891
Module end 'content' 0.01380.0020 878.234442.3047
Script end 0.0158  920.5391 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002415.0837140.0002
Check MTime0.00106.4531140.0001
Mysql Total
Database connection0.00116.985810.0011
Mysqli_queries0.002817.466830.0009
Looping result0.00000.069010.0000
Template Total0.001610.110.0016
Template load0.00085.249510.0008
Template processing0.00084.808310.0008
Override
Cache load0.00053.424610.0005
General
dbfile0.00138.132480.0002
String conversion0.00000.055540.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs