Forums / Setup & design / Images with round corners

Images with round corners

Author Message

Fredrik Ardmar

Sunday 23 August 2009 8:48:36 am

Hi

Anyone knows how to make round corners with image magick and using the built in image handling system in eZ?

I have read in the forum about some solutions using one large mask and then composing this with your image. Problem is that I don't know the exact size of the image so we need to use one image/mask for each corner.

With plain image magick it would be something like this:

composite -gravity NorthEast rounded-ne.png lake.png lake-1.png
composite -gravity NorthWest rounded-nw.png lake-1.png lake-2.png
composite -gravity SouthEast rounded-se.png lake-2.png lake-3.png
composite -gravity SouthWest rounded-sw.png lake-3.png lake-4.png

Now the questions is how to merge this with how eZ handles images.

Any ideas?

Fredrik

http://www.areadigital.org

Custom google maps with eZ Publish

http://www.meresverige.dk
http://dsbfirst.meresverige.dk

Heath

Sunday 23 August 2009 10:19:52 am

I found this related article on eZpedia

http://ezpedia.org/en/snippet/template_logic_and_settings_to_provide_rounded_corners_on_image_aliases

Cheers,
Heath

Brookins Consulting | http://brookinsconsulting.com/
Certified | http://auth.ez.no/certification/verify/380350
Solutions | http://projects.ez.no/users/community/brookins_consulting
eZpedia community documentation project | http://ezpedia.org

Fredrik Ardmar

Sunday 23 August 2009 8:00:45 pm

Hi Heath

Thanks for the swift answer.

This is actually the same article i started with. This approach is fairly straight forward and after some tweaking I manged to get this to work.

The main disadvantage is that the mask and the image needs to be exactly the same size. Meaning that you need to work with fixed size images. This is ok for some of our project but many projects have a fixed image width but a flexible height. All dependent on the original image ratio.

So what I need is an approach where 4 corner images/masks are composed on the image creating the mask.

Any ideas?

Fredrik

http://www.areadigital.org

Custom google maps with eZ Publish

http://www.meresverige.dk
http://dsbfirst.meresverige.dk

Heath

Sunday 23 August 2009 9:08:08 pm

Fredrik,

Your welcome. If I can share I try to do it quickly so If I can't help I can do the next best thing, get out of the way.

In truth I just don't have time to go find the example I remember using before. I used to do so much custom image magic in years past, with all my examples dust to the wind.

I had hoped the article helps get some started. I hope it guides them along the path towards the next more complicated example. If you find one, do you mind adding a link in the article?

Best wishes. *steps to the side*

Cheers,
Heath

Brookins Consulting | http://brookinsconsulting.com/
Certified | http://auth.ez.no/certification/verify/380350
Solutions | http://projects.ez.no/users/community/brookins_consulting
eZpedia community documentation project | http://ezpedia.org

/dev/null

Sunday 23 August 2009 9:20:15 pm

<i>http://stackoverflow.com/questions/718314/rounding-corners-of-pictures-with-imagemagick
http://ez.no/developer/forum/setup_design/rounded_corners_on_images
http://ajaxian.com/archives/googles-rounded-corner-generator
http://www.imagemagick.org/discourse-server/viewtopic.php?f=1&t=8401
</i>

eZpedia community documentation project: http://ezpedia.org

Fredrik Ardmar

Monday 24 August 2009 6:37:11 pm

Thanks for the great input..

As I see it the ImageMagick command needs to be executed in one command in order to run with in eZ? Also it has to be done without creating any temporary files or masks since these will be hard to clean up?

Anyone figured out how to add 4 separate corners in an image together with convert in one command? Then how to translate this into a filter for image.ini?

Fredrik

http://www.areadigital.org

Custom google maps with eZ Publish

http://www.meresverige.dk
http://dsbfirst.meresverige.dk

Betsy Gamrat

Friday 20 November 2009 5:20:41 am

One solution is to use PostParameters to round the corners of *ALL* images. This is because the PostParameters setting isn't escaped onto the command line, as are the Filters. I couldn't get the ImageMagick command line options used for rounding to pass properly through the escaping using Filters.

Formats that don't support transparency don't display the rounded corners, thus, .jpgs are unchanged, unless you choose to use one of the 'rounded' aliases.

ez/settings/override/image.ini.append.php

<?php /* #?ini charset="utf-8"?

[AliasSettings]
AliasList[]=rounded-small
AliasList[]=rounded-medium
AliasList[]=rounded-large

[rounded-small]
MIMEType=image/png
Reference=small

[rounded-medium]
MIMEType=image/png
Reference=medium

[rounded-large]
MIMEType=image/png
Reference=large

[ImageMagick]
IsEnabled=true
ExecutablePath=/usr/local/bin
Executable=convert
ExecutableUnix=convert

# This line causes ALL images to have their corners rounded. Only .gifs and .pngs will display with rounded corners, .jpgs
# will display with sharp corners, because they don't support transparency. If a .jpg image is uploaded, the display class
# must be set to one of the above for the rounded corner version to display.
#
# The PostParameters settings must also be applied before the destination file name, modify /var/www/html/ez/lib/ezimage/classes/ezimageshellhandler.php
#
# Thanks to: http://www.imagemagick.org/Usage/thumbnails/#rounded
PostParameters=\( +clone -threshold -1 -draw "fill black polygon 0,0 0,10 10,0 fill white circle 10,10 10,0" \( +clone -flip \) -compose Multiply -composite \( +clone -flop \) -compose Multiply -composite \) +matte -compose CopyOpacity -composite

*/ ?>

I modified /var/www/html/ez/lib/ezimage/classes/ezimageshellhandler.php to place the Filters and PostParameters between the source and destination filenames, because this is how I usually work with ImageMagick.

/var/www/html/ez/lib/ezimage/classes/ezimageshellhandler.php

if ( $filters !== false )
{
foreach ( $filters as $filterData )
{
$argumentList[] = $this->textForFilter( $filterData );
}
}

/* Move PostParameters up before the destination file is named */
if ( $this->PostParameters )
$argumentList[] = $this->PostParameters;

$destinationURL = $destinationMimeData['url'];

Finally, although I tried to use the debug settings to output the commandline, I didn't have any luck. To support development, I added the following line to the same file:

file_put_contents('/tmp/eZ.out',$systemString."\n",FILE_APPEND);

/* Added just before the execution */
system( $systemString, $returnCode );[/

eZ debug

Timing: Jan 18 2025 02:02:10
Script start
Timing: Jan 18 2025 02:02:10
Module start 'content'
Timing: Jan 18 2025 02:02:10
Module end 'content'
Timing: Jan 18 2025 02:02:10
Script end

Main resources:

Total runtime0.2017 sec
Peak memory usage4,096.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0067 589.1406180.8359
Module start 'content' 0.00670.0056 769.9766106.0547
Module end 'content' 0.01230.1893 876.0313534.7734
Script end 0.2016  1,410.8047 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00351.7387200.0002
Check MTime0.00140.6789200.0001
Mysql Total
Database connection0.00090.448810.0009
Mysqli_queries0.148573.64741410.0011
Looping result0.00160.78161390.0000
Template Total0.188993.710.1889
Template load0.00090.436410.0009
Template processing0.188093.216310.1880
Override
Cache load0.00060.296010.0006
Sytem overhead
Fetch class attribute can translate value0.00100.494910.0010
XML
Image XML parsing0.00020.119010.0002
General
dbfile0.00432.1257200.0002
String conversion0.00000.013430.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
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0002 secs