Closed (works as designed)
Project:
ImageCache Actions
Version:
7.x-1.1
Component:
Custom Actions Module
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
7 May 2013 at 18:58 UTC
Updated:
18 Mar 2016 at 19:27 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
fietserwinThis is done with effects form Drupal core only: scale to 300 wide, then crop to 200x300 (anchor: center-top). Please file a feature request against Drupal core to add the anchor parameter to "crop and scale" as well (if no issue already exists for this)
If you enable the Image styles admin sub-module you can import the style below:
a:5:{s:4:"isid";s:2:"40";s:4:"name";s:12:"test-1989350";s:6:"module";N;s:7:"storage";i:1;s:7:"effects";a:2:{i:111;a:12:{s:5:"label";s:7:"Schalen";s:4:"help";s:131:"Door te schalen worden de originele verhoudingen behouden. Als één van de dimensies wordt ingevuld zal de andere worden berekend.";s:15:"effect callback";s:18:"image_scale_effect";s:19:"dimensions callback";s:22:"image_scale_dimensions";s:13:"form callback";s:16:"image_scale_form";s:13:"summary theme";s:19:"image_scale_summary";s:6:"module";s:5:"image";s:4:"name";s:11:"image_scale";s:4:"data";a:3:{s:5:"width";s:3:"300";s:6:"height";s:0:"";s:7:"upscale";i:0;}s:4:"ieid";s:3:"111";s:4:"isid";s:2:"40";s:6:"weight";s:3:"-10";}i:110;a:12:{s:5:"label";s:10:"Bijsnijden";s:4:"help";s:105:"Door bij te snijden worden delen van een afbeelding verwijderd zodat deze binnen de opgegeven maten past.";s:15:"effect callback";s:17:"image_crop_effect";s:19:"dimensions callback";s:23:"image_resize_dimensions";s:13:"form callback";s:15:"image_crop_form";s:13:"summary theme";s:18:"image_crop_summary";s:6:"module";s:5:"image";s:4:"name";s:10:"image_crop";s:4:"data";a:3:{s:5:"width";s:3:"300";s:6:"height";s:3:"200";s:6:"anchor";s:10:"center-top";}s:4:"ieid";s:3:"110";s:4:"isid";s:2:"40";s:6:"weight";s:2:"-9";}}}Comment #2
bigfatguy commentedThe problem if I scale and crop separately I'll get black (or white) canvas in background of image, if it has non suitable proportions for such scaling. So I have to make scaling to bigger size f.e. 350x250, than crop to 300x200 with top anchor. But such workaround crops a lot on some images that suites that proportion in favor of those that doesnt.
There is feature request http://drupal.org/node/1252606#comment-5637638 to add anchoring to crop and resize, but it is for D8, as far as I understood.
Comment #3
dman commentedI guess you could try the aspect switcher to sort this out for you;
If image proportions are wider than a ratio 2:3, then scale vertically until it's 300 high, then crop the sides to 200 wide
If proportions are squarish or tallish (less than 2:3) then scale to 200 wide, then crop from the top to 300 high
Or something a bit like that
Interestingly, it was a task a bit like this that started the entire imagecache_actions project..
When preparing albums like this one http://thevintageaviator.co.nz/image/tid/94
where a mix of portrait and landscape pics were ALL to be thumbnailed into a landscape preview, 80% of the portraits (which were real head-and-shoulder or full-body 'portraits') looked silly as the default centered crop would cut off everyones face.
So I created the upper 2/3 weighted crop as a custom action. And once I'd solved that I started adding tricky effects everywhere...
Comment #4
fietserwinI did some quick calculations with a portrait and landscape size, but extremer ratio's will indeed fail :( dman's solution looks better.
Comment #5
fietserwinI did some quick calculations with a portrait and landscape size, but extremer ratio's will indeed fail :( dman's solution looks better.
Comment #6
dman commentedYeah, that works exactly as planned

200x300_wide
200x300_tall
200x300_top
Comment #7
ezoulou commentedGreat! Thanks for taking the time to report.
Comment #8
fietserwinI guess this has been solved by now. Feel free to reopen if not, adding any additional info possible.