By kostal on
I would like to add an "Image Style" that resizes an image by percentage instead of a fixed pixel. In Drupal 6, Image Cache allowed you to do this (http://drupal.org/node/163561).
I know Image Cache is now in the core... so would I have to alter the core? That's something I really want to avoid. Write a module? I have PHP experience but have never written a module and don't really know where to start. It seems like this wouldn't be too big of a fix but I'm not really sure where to go...
Comments
_
Since it didn't make it to the core d7 version, seems like the http://drupal.org/project/imagecache_actions module would be a good place for it. Examining the code should provide you with what you need to know to modify an existing action to do what you want.
Thanks, I did see that but
Thanks, I did see that but wasn't sure about it. I'll do some experimenting and report back.
ImageAction Crashes System
I've tried using the Image Action module and it crashes the system when I try to enable the "write your own php" or when I actually try to apply one of the effects to an image style. Maybe it's best I just use Drupal 6, since I know it can do everything I need. But dang I was really digging 7.
Option available even in Drupal 5
I am also wondering why the % resize option is not available on D7 core neither in imagecache_actions.
Really needing this...
Any update on this? Really
Any update on this?
Really needed.
Quentin Campbell
One solution is switching from GD2 to ImageMagik
Imagecache Actions module should be the place to go, but I had no luck with the custom action configuration... I can't figure out if the problem is coming from the module for D7 that doesn't support %, core ImageCache module, the GD2 library, or something else.
Anyway I switched my image toolkit from GD2 to ImageMagick, and install the ImageMagick Raw Effect module, that adds a new effect option to the Image Styles page so you can create your own raw imagemagick command.
In my case, the raw imagemagik command I use is :
-thumbnail 10%Documentation about resize commands:
http://www.imagemagick.org/script/command-line-options.php?#resize
http://www.imagemagick.org/script/command-line-options.php?#thumbnail
http://www.imagemagick.org/script/command-line-processing.php?ImageMagic....
One problem you could have switching from GD2 to ImageMagick is that the Imagecache Actions effects are not well supported (at this time), as explained in the main project page module.
Hello all you can just set up
Hello all
you can just set up imagecache_action module and in the image style select manual action, and add code like this
and you will receive something like percentage image style.
Hope that would help to anybody.
Thanks you ! Works like a
Thanks you ! Works like a charm.
my error
Hi, i get this error, but i dont understand this.
Other all styles, round, etc... it´s ok.
Any suggestion?
Very thk!
Call to undefined function imagecache_actions_get_image_context() in C:\xampp\htdocs\sellosalepuz5\sites\all\modules\imagecache_actions\customactions\imagecache_customactions.module on line 125
doc
Well, sorry i find the docs for custom actions.
After i post the results.
thk
Hi lgrtm,All you need to do
Hi lgrtm,
I had this problem too. To make this work I added a couple of lines to imagecache_customactions: -
Good luck with your project...
David
Doesn't allow custom code!
Hi,
Looking to solve the same problem: percentege image style.
I just follow all the instructions on the Readme File:
1) Installed ImageCache actions module
2) run update.php
3) create a new image style
4) add a custom action effect
But when I want to insert the code you posted inside the custom action effect option, the window to insert the PHP code is gray with a "return TRUE;" code inside. I can't modify it to insert your code!
P.D. Are the "soft dependencies" needed to run the code?
any clues?
Best regards
You have to enable the 'PHP
You have to enable the 'PHP filter' module. After that you can paste it there.
Hi, Using new version you
Hi, Using new version you can, for example, to make static height and flexible width almost same code but return true like:
Any idea how to make the
Any idea how to make the image a percentage of the screen width so it looks good with responsive design and will change automatically without having to set any breakpoints?
% of Screen Width
@LTech, this is exactly what I came looking for. Have you found a resolution?
We could of course do this in the css, but there may be a better way wrt responsivness.
Now there's a module for this
https://drupal.org/node/2189449
100%x100%
Just want to mention if you want to create 100%x100% (I've need it on image preview when adding/editing node) then just create EMPTY image style (without any actions!) with name something like 'Original (100%x100%)'. It will left image in original state.