Closed (fixed)
Project:
ImageCache Actions
Version:
7.x-1.x-dev
Component:
Canvas Actions Module
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
2 Apr 2010 at 17:09 UTC
Updated:
24 Jan 2016 at 12:44 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
eojthebraveIf I understand what you're trying to to I think you can use the imagecache "Scale" action and click the "Allow upsizing" checkbox. This will allow you to take images that are smaller than your desired dimensions and upscale them to the correct size and allow images larger than your desired dimensions to be scaled down.
Comment #2
drewish commentedmight be better to ask over in this queue.
Comment #3
dman commentedstretching images generally looks horrible.
If you want a vignette thing , perhaps imagecache_scale9 is a better result.
I don't think we'll be adding resize to overlays
Comment #4
dman commentedI can't see this happening.
Comment #5
raintonr commented+1 for this as I'd find it very useful:
- Have an overlay resized (including upscale if that's appropriate) to fill one (preserving the aspect ratio of the overlay) or both (ignoring the aspect ratio of the overlay) of the dimensions of the target image.
Could this be an option on the canvasactions_file2canvas action?
The reason for this is that sometimes you want a single rule to watermark images of any size. Clearly when working on different images, if the overlay isn't resized to match the target this could result in a watermark that is hardly visible (watermark too small for image) or too large (watermark 'overflows' image).
Comment #6
raintonr commentedTurned out this was simple enough. Please see enclosed patch.
I added a 'Scale' checkbox to the 'Overlay (watermark)' action which is off by default (preserves original action).
This patch was made against v6.x-1.7 packaged 2010-05-25.
Comment #7
bdone commentedPatch #6 works for me.
When upscaling the overlay, I'd prefer to use imageapi_image_resize() (to ignore aspect ratio).
Perhaps the UI could allow a choice?
Comment #8
NaX commentedWorked great for me, this actually prevents a PHP error for me when the watermark is larger than the canvas. As I don't have control over the size of the images my client uploads, this is a nice workaround/fix for me.
Error:
When I used a smaller watermark that was much smaller than the image, the positioning was off. To correct this the only thing I changed was for it to not up scale.
EG:
imageapi_image_scale($overlay, $image->info['width'], $image->info['height'], FALSE);I actually think this
imageapi_image_scale()call should be the default if the overlay is larger than the image and the only option should be if it should up scale when the overlay is smaller.Comment #9
christian death commentedWork perfect.
But for Drupal 7 change
imageapi_image_scale($overlay, $image->info['width'], $image->info['height'], TRUE);to
image_scale($overlay, $image->info['width'], $image->info['height'], TRUE);Comment #10
RobW commentedChiming back in, I obviously went a different way (4 side specific overlays) for the project I was working on a couple months ago, but am happy that this issue got some love. Thanks for writing a working patch, will test as soon as I have some time outside of client work.
Comment #11
christian death commentedComment #12
fietserwinCanvas actions and differently sized images do not cooperate nicely, certainly not when using Imagemagick. However, I think we should better support this. Certainly for image masks like blurred edges it can be expected that one wants to resize the mask first to the current image size before applying it.
Patches against the latest 7.x-1.dev are welcome and will be considered.
Comment #13
fietserwinPostponing until after the 7.x-1.0 release. I don't expect to see any patch here soon that:
- will implement it for imagemagick as well.
- will implement it for both underlay and overlay.
Patches that do the above remain welcome.
Comment #14
Ace Cooper commentedI'm working on a e-commerce catalog, that uses photoes of different sizes and proportions.
Naturally, I bumped into the issue of watermark scaling.
In my case the watermark was sometimes larger than the catalog images.
I've decided to add a 0-100% scaling for overlay image (watermark) in case you might need extra margins.
If you leave the Scale input empty - the overlay image shall have it's original dimensions.
Below is a patch against ImageCache Actions 7.x-1.x-dev dated 2012-Dec-05 (before/after).
UPD. The patch tested only for GD library. The scale of overlay (watermark) is relative to the canvas/underlay image.
Comment #15
dman commentedCool. Patch reads well. Looks like it would be a good help.
Comment #16
fietserwinThanks for posting.
As mentioned in #13, I would also like to see the patch cover the underlay effect and support the imagemagick toolkit.
Comment #17
Ace Cooper commentedI agree, that my patch only solves a partial usecase.
In my catalog the images have low resolution and dimensions, so the downscaling of watermark was necessary.
But in case the underlay images are much larger than the watermark - the overlay will become grainy after upscaling.
Hence I also have to add an option to limit overlay upscaling above original dimensions (or other limit like 2x, 3x, etc.)
The proportions of the watermark are not lost after scaling (there is a "TRUE" parameter to preserve the ratio).
You can check it yourself here, notice different proportions of most pictures in the gallery.
As for ImageMagick - I have no idea of the ways it is different from GD.
I can make no judgement on code compatibility, so I shall trust fietserwin on the matter.
I kindly ask anyone better versed with ImageMagick to take a look at this patch.
Comment #18
fietserwin- OK, you are right with the aspect ratio, While reviewing, I just noted that the width and height were calculated using different values.
- Imagemagick is indeed quite different. If you can refactor that part by moving it into the GD specific processing I will have a look at the Imagemagick processing.
Regarding additional optins:
- Do we still need that checkbox to preserver or not the aspect ratio?
- Do we need an option to limit upscaling?
- Do we need a repeat option?
Or do we start with a simple version and see what requests we do get?
Comment #19
dman commentedI think
* always preserve the aspect ratio. Anything else is super-ugly always.
* either don't limit upscaling at all, or expose the option as a checkbox. If someone said they want the watermark 20% of the image and uploads even a giant image, they should still get that.
* repeat will be noce, but a different issue. You need to add spacing and tiling options for that. New feature request.
And yes, the default should be empty/unset to preserve the 'normal' behavior, and not jump to completely covering everything 100% :-)
Comment #20
ttkaminski commentedUpdated the patch in #14 with the following:
- Always keep aspect ratio. The overlay is scaled based on the widths of the images.
- Fixed
image_imagemagick_overlay()to properly apply the new overlay sizeComment #21
ttkaminski commentedAnother tweak:
- Null out the default overlay scale so that default action isn't changed (ie. overlay isn't scaled)
Comment #22
thijsvdanker commentedRerolled the patch from #21 and changed the $image-ops to use $realPath instead of $layer->source.
Comment #23
candelas commentedpatch #22 working
Thank you all :)
Comment #24
MmMnRr commentedPatch from comment #22 worked for me.
Thank you!
Comment #26
fietserwinCommitted this feature. I added some form validation, additional help and removed the ImageMagick support for now, that resized the source, not the overlay. I will look at that shortly.
Thanks all, as I found it hard to credit just one of you as the author, I did not credit any of you as author.
Comment #28
fietserwinThat was not too difficult: http://www.imagemagick.org/Usage/layers/#composite, not -resize but -geometry was to be used.