Forums / Developer / Imagemagick resize option with caret (^)

Imagemagick resize option with caret (^)

Author Message

Piotrek Karaś

Saturday 17 May 2008 2:25:22 am

I'm trying to use imagemagick's resize option with minimum image size limit parameter, which is a caret (^). Unfortunately, it fails. Here's an example:

Filters[]
Filters[]=square=-resize %1x%2^ -crop %3x%4+0+0 -gravity center

Something wrong with that filter, eZ Publish, or maybe the library itself? The result is:

Failed executing... Error code: 1

Thanks,
Piotrek

--
Company: mediaSELF Sp. z o.o., http://www.mediaself.pl
eZ references: http://ez.no/partners/worldwide_partners/mediaself
eZ certified developer: http://ez.no/certification/verify/272585
eZ blog: http://ez.ryba.eu

Bartek Modzelewski

Saturday 17 May 2008 9:37:15 am

Hi Piotrek,

have you tried to execute your command directly in command line using <i>convert</i> ?

Bartek

Baobaz
http://www.baobaz.com

Piotrek Karaś

Sunday 18 May 2008 1:08:32 am

Hey Bartek,

Thanks for the tip - I keep forgetting the differences between gd and imagemagick ;)

So, the thing was not an error, but a version problem - this caret option is a relatively new solution (which by the way is totally curious to me... so many years without a basic geometry setting...). None of my version supports that, so I found another filter trick:

Filters[]=squarefix=-resize x%1 -resize '%1x<' -resize 50% -gravity center -crop %2x%3+0+0 +repage

--
Company: mediaSELF Sp. z o.o., http://www.mediaself.pl
eZ references: http://ez.no/partners/worldwide_partners/mediaself
eZ certified developer: http://ez.no/certification/verify/272585
eZ blog: http://ez.ryba.eu

*- pike

Monday 28 July 2008 7:50:45 am

Hi

I'm trying to tackle the same problem. With the caret, my command would be

Filters[]=imthumb48=-scale 48x48^ -crop 48x48! -gravity Center 

but you need im 6.3.8-2 :

> http://www.imagemagick.org/script/changelog.php
> 2008-01-24 6.3.8-2 Cristy <quetzlzacatenango@image...>
> Support a ^ meta character in an image geometry (.e.g convert 640x480.png -resize 240^ returns a 320x240 result).

can you explain how your voodoo works ?

Filters[]=squarefix=-resize x%1 -resize '%1x<' -resize 50% -gravity center -crop %2x%3+0+0 +repage

curious,
*-pike

---------------
The class eZContentObjectTreeNode does.

Piotrek Karaś

Monday 28 July 2008 8:53:52 am

Hi,

I found that instruction as one of the possible workarounds of the caret problem, somewhere in a IM forum. It is supposed to scale down, down to the smaller picture size, and it uses some resize to read image sizes (as far as I remember, IM had some inconveniency about reading that). Unfortunately, I won't be able to decode that word by word - I'm IM beginner ;)
Oh, and that one in particular is used for square images only, I think.

--
Company: mediaSELF Sp. z o.o., http://www.mediaself.pl
eZ references: http://ez.no/partners/worldwide_partners/mediaself
eZ certified developer: http://ez.no/certification/verify/272585
eZ blog: http://ez.ryba.eu

*- pike

Friday 29 August 2008 2:55:08 pm

Hi

After two espressoos I could suddenly read it. For a short moment. Let me see if I can repeat that :-)

Filters[]=squarefix=-resize x%1 -resize '%1x<' -resize 50% -gravity center -crop %2x%3+0+0 +repage
[mythumb]
Filters[]=squarefix=96;48;48

-resize x%1 resizes to height 96. the width is chosen to maintain the aspect ratio

-resize '%1x<' sizes UP until the width minimally 96, if required. this will happen if you have a vertical (portrait) image.

-resize 50% scales it down to, not accidently, 48>x48>

-gravity center -crop %2x%3+0+0 +repage then crops to 48x48 centered. not sure why the gravity is before the crop.

I guess that would always work, the only problem is it sizes up for vertical images, eg 133% for a 3x4 image. I'm not sure if IM makes that blurry.

$2c,
*-pike

.

---------------
The class eZContentObjectTreeNode does.

Piotrek Karaś

Tuesday 09 September 2008 9:22:21 pm

Those espressos must have been black as hell! ;)

Yes, this method sometimes produced blury results, but that it mostly limited to a situation where the source image is relatively small. Otherwise, seems to work fine for me.

And yes, you may differ this about resizing order and size, depending on whether you expect more horizontal or vertical images, for better results. In my case, I wanted rectangular images, and decided not to pay much attention to that problem since there was no way of telling that.

It's surprising that all key, and apparently basic functionalities, have been introduced so recently... (speaking the caret)...

--
Company: mediaSELF Sp. z o.o., http://www.mediaself.pl
eZ references: http://ez.no/partners/worldwide_partners/mediaself
eZ certified developer: http://ez.no/certification/verify/272585
eZ blog: http://ez.ryba.eu

eZ debug

Timing: Jan 18 2025 11:32:44
Script start
Timing: Jan 18 2025 11:32:44
Module start 'content'
Timing: Jan 18 2025 11:32:45
Module end 'content'
Timing: Jan 18 2025 11:32:45
Script end

Main resources:

Total runtime0.9162 sec
Peak memory usage4,096.0000 KB
Database Queries208

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0051 587.7344180.8281
Module start 'content' 0.00510.7535 768.5625636.1094
Module end 'content' 0.75850.1576 1,404.6719345.0703
Script end 0.9161  1,749.7422 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00390.4255210.0002
Check MTime0.00140.1576210.0001
Mysql Total
Database connection0.00050.056510.0005
Mysqli_queries0.826190.16922080.0040
Looping result0.00250.27552060.0000
Template Total0.889697.120.4448
Template load0.00220.239420.0011
Template processing0.887496.850720.4437
Template load and register function0.00010.010710.0001
states
state_id_array0.00100.112710.0010
state_identifier_array0.00160.178120.0008
Override
Cache load0.00200.2167550.0000
Sytem overhead
Fetch class attribute can translate value0.00130.146540.0003
Fetch class attribute name0.00110.124680.0001
XML
Image XML parsing0.00110.115340.0003
class_abstraction
Instantiating content class attribute0.00000.0029110.0000
General
dbfile0.00230.2536280.0001
String conversion0.00000.000430.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
4content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
7content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
15content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
6content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
5content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 39
 Number of unique templates used: 7

Time used to render debug report: 0.0002 secs