I have tried doing rounded corners using following actions but the image files get too big

Scale And Crop*	300x200	
Change File format	Convert to : png	
Rounded Corners	Radius: 16px

image without rounded corner is 15kb
with rounded corner around 115kb

I have tried doing the same with

Scale And Crop	300x200	
Define Canvas	300x200 (center, center)  #ffffff  under image 	
Rounded Corners	Radius: 16px

but the file size is the same as a png around 115kb
on closer inspection trying to insert an imagecached image on photoshop I get

Could not complete your request because an unknown or invalid JPEG marker type is found.

if I rename the file as .png then photoshop opens up the image and the rounded corners are transparent !??!! (instead of white)

I have flushed the preset and made sure the corresponding folder is empty
I am calling the imagecached image directly after clearing the browser cache
but to no avail

Finally I came up with the following set of actions which produce a small file size with rounded corners

Change File format	Convert to : png	
Scale And Crop	300x200	
Rounded Corners	Radius: 16px	
Define Canvas	300x200 (center, center)  #ffffff  under image 	
Change File format	Convert to : jpg

and I get 15kb correct jpg (with .jpg extension) files

Comments

dman’s picture

Status: Active » Fixed

Correct.
That's what the instructions say:

Note: the rounded corners effect uses true alpha transparency masking.
This means that this effect will fail to be saved on jpegs
unless you either

  • convert the image to PNG (using the coloractions filter for that),
  • define a canvas underneath it (using canvasactions-define-canvas) or
  • underlay a solid color (using coloractions-alpha-flatten) or
  • underlay a background image (canvasactions-underlay)

as a later part of this imagecache pipeline.

Saving it as a PNG gives you transparency but inefficiently large file sizes (and the conversion to png does not accurately change the suffix). There's not much we seem to be able to do about that Though I've looked at it before

Saving it as a jpeg is fine provided you follow instruction #2 instead.

You don't need the 'convert to png' / 'convert to jpg' steps, but otherwise you've follwoed the instructions correctly.

giorgosk’s picture

these instructions will create jpg image with correct extension

Scale And Crop	400x300	
Rounded Corners	Radius: 5px	
Define Canvas	400x300 (center, center)  #ffffff  under image 	
Change File format	Convert to : jpg

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Sinan Erdem’s picture

Version: » 6.x-2.0
Status: Closed (fixed) » Active

Converting to JPEG disables rounded corners. I tried it with either adding a canvas, or a background image separately...

Sinan Erdem’s picture

Sorry for my previous comment. I was doing the order wrong as:

Scale And Crop 400x300
Define Canvas 400x300 (center, center)  #ffffff  under image
Rounded Corners Radius: 5px
Change File format Convert to : jpg

Making it as mentioned at comment #2 works...

Sinan Erdem’s picture

Status: Active » Closed (fixed)
asb’s picture

Status: Closed (fixed) » Active

This results in pure white image files with 900x250px dimensions and without rounded corners:

Change File format	Convert to : png
Focus Scale And Crop	900x250 high strength
Sharpen	radius: 0.5, sigma: 0.5, amount: 100, threshold: 0.05
Define Canvas	900x250 (center, center)  #ffffff  under image
Rounded Corners	15px | 15px | 0px | 0px
Change File format	Convert to : jpg

This gives me an uncropped segment of the original image (seems to break "Focus Scale And Crop"), again without rounded corners:

Change File format	Convert to : png
Focus Scale And Crop	900x250 high strength
Sharpen	radius: 0.5, sigma: 0.5, amount: 100, threshold: 0.05
Define Canvas	900x250 (center, center)  #ffffff  under image
Overlay: source image to canvas	xpos:0, ypos:0 alpha:100%
Rounded Corners	15px | 15px | 0px | 0px
Change File format	Convert to : jpg

This produces scaled and cropped images, of course without rounded corners:

Focus Scale And Crop	900x250 high strength
Sharpen	radius: 0.5, sigma: 0.5, amount: 100, threshold: 0.05
Rounded Corners	15px | 15px | 0px | 0px

If the comment above would be correct, this image whould not even be saved.

ImageAPI is configured to use ImageMagick, because GD library 2.0 on Debian Lenny results in these warnings:

GD Image Filtering	Low Quality / Poor Performance
The installed version of PHP GD does not support image filtering(desaturate, blur, negate, etc). It was probably compiled using the official GD libraries from http://www.libgd.org instead of the GD library bundled with PHP. You should recompile PHP --with-gd using the bundled GD library. See PHP Manual for more information. A slower implementation of imagefilter() written in PHP will be used in the interim.

GD Image Rotation	Low Quality / Poor Performance
The installed version of PHP GD does not support image rotations. It was probably compiled using the official GD libraries from http://www.libgd.org instead of the GD library bundled with PHP. You should recompile PHP --with-gd using the bundled GD library. See PHP Manual for more information. A slower implementation of imagerotate() written in PHP will used in the interim.

Also, when disabling ImageMagick and enabling GD, I'm getting the even worse results: not even white image files are generated, and none of this gives a preview image.

Does this Imagecache action actually work for anyone? Can Debian users safely uninstall 'Imagecache actions' because Imagemagick isn't spported, and the GD library is incompatible?

Sinan Erdem’s picture

Can you try moving the rounded corners action on top of the list? at least before defining canvas? This way it works for me. All the images with rounded corners in this website is created by using this action: http://itsme.eu/

asb’s picture

@etcetera9: Thanks, I'll try that. Are you using ImageMagick or GD?

dman’s picture

To simplify the test cases - do you still encounter the problem with the documented way to do it?
Just starting with "rounded corners" + "define canvas"

There should be no need to convert to PNG and back to JPEG during any one action, that would actually have zero effect, as internally the data is treated the same, it's only on save that the file extension is used.
You /can/ do transparency actions in memory on images originally loaded from a jpeg with GD or imagemagick pipeline, so layering & watermarks work. it's just that any 'transparent' parts get flattened on save - which is why using rounded corners to trim the image but not providing a replacement color doesn't work after saving a jpeg.

I don't know how badly the limited GD version does (in general) with imagecache actions though. I've heard of it on older systems, but don't have a server I've seen it on.

Sinan Erdem’s picture

I am using GD2 library on Ubuntu...

asb’s picture

I tried some more; GD isn't working for me at all on Debian Lenny, so that's no option - it's frightening enough that GD seems to be that much version dependent, and there are lots of hosts out there with older environments than "Lenny".

Enabled: "Imagecache Canvas Actions" and "Imagecache Color Actions", both in version 6.x-1.8. When adding a "Rounded corners" action, I'm getting a yellow message:

Rounded corners are not currently supported by using imagemagick. This effect requires GD image toolkit only.

So there's seems to be not much point in further experiments - unless the message lies ;-/

Anyway, for argument's sake: This does not give rounded corners:

Focus Scale And Crop	600x250 high strength
Sharpen	radius: 0.5, sigma: 0.5, amount: 100, threshold: 0.05
Rounded Corners	15px | 15px | 0px | 0px
Define Canvas	 left: right: top: bottom:  #ffffff  under image

When adding a "Define Canvas" action, I'm getting another yellow message:

Define Canvas not currently supported by using imagemagick. This effect requires GD image toolkit only.

Nothing changes when I add a "Change File format Convert to : jpg" action as last step.

You /can/ do transparency actions in memory on images originally loaded from a jpeg with GD or imagemagick pipeline, so layering & watermarks work. it's just that any 'transparent' parts get flattened on save - which is why using rounded corners to trim the image but not providing a replacement color doesn't work after saving a jpeg.

That part I don't understand. Isn't this exactly what I'm doing???

dman’s picture

Rounded corners are not currently supported by using imagemagick. This effect requires GD image toolkit only.

is your answer then.
Someone who knows how to get that effect with ImageMagick may be able to provide more hints.
If there is an answer, it can be applied using custom_actions or http://drupal.org/project/im_raw until such time as they create a patch.

dman’s picture

I think 'define canvas' under imagemagick is working for me in 6.x-2.x-dev - my test site does it, though this support was only added earlier this year. So, it's in -dev.

But as 'rounded corners' has not been added by any imagemagick developer, then it won't help the actual task

asb’s picture

Version: 6.x-2.0 » 6.x-2.x-dev

Upgraded to imagecache_actions 6.x-2.x-dev 2011-Mar-11 and tried again with this:

Define Canvas	 left: right: top: bottom: under image
Focus Scale And Crop	600x250 high strength
Sharpen	radius: 0.5, sigma: 0.5, amount: 100, threshold: 0.05
Rounded Corners	15px | 15px | 0px | 0px
Change File format	Convert to: jpg, quality: 85%

and this:

Define Canvas	 left: right: top: bottom: under image
Rounded Corners	15px | 15px | 0px | 0px
Focus Scale And Crop	600x250 high strength
Sharpen	radius: 0.5, sigma: 0.5, amount: 100, threshold: 0.05
Change File format	Convert to: jpg, quality: 85%

Same result, no rounded corners :-(

dman’s picture

But as 'rounded corners' has not been added by any imagemagick developer, then it won't help the actual task

giorgosk’s picture

on the latest dev of imagecache I have actually created rounded corners using just

Change File format	Convert to: png
Scale And Crop	225x160
Rounded Corners	Radius: 5px

but scale and crop is optional

asb’s picture

@GiorgosK: Interesting. This works for me in preview (for the PNG Druplicon, but not with Jpegs as source images. Actually, the "Convert to: png" does not convert the file format:

$ file IMG_4443_SAMPLE.JPG 
IMG_4443_SAMPLE.JPG: JPEG image data, JFIF standard 1.01

Tested with imagecache_actions 6.x-2.x-dev 2011-Mar-11, imagecache 6.x-2.0-beta10 2009-Aug-19, and ImageMagick 6.3.7.

Upgraded to imagecache 6.x-2.x-dev 2011-Apr-25, exactly the same result. Great.

giorgosk’s picture

did you read reply #15 (imagemagick does not support rounded corners ??)
try using the GD2 instead

asb’s picture

Status: Active » Closed (won't fix)

GD what? #8

OK, there's no point to continue this; ImageMagick is not supported, and there is no workaround, so Imagecache Actions is useless on Debian, thus there is no "Do rounded corners the right way" for us 25% on Debian hosts. Closing.