| Module | ActionView::Helpers::ImageMagickMacroHelper |
| In: |
actionpack/lib/action_view/helpers/image_magick_macro_helper.rb
|
Provides helpers for using ImageMagick. These helpers rely on the corresponding ImageMagick macro in the controller. See ActionController::Macros::ImageMagick::ClassMethods
You can use the following ImageMagick commands with this helper: (see imagemagick.org/script/command-line-options.php for a description of what they do).
And, as a special service to Rails users, this extension has a method that is not available for ImageMagick, but can be very useful:
You can also define and use your own ‘recipes’. See the documentation for ActionController::Macros::ImageMagick::RecipeSet
Returns the path for the image, which will be rendered with the given ImageMagick commands.
filename_or_params and commands works the same as for imagemagick_tag. options does nothing.
The workings of this function depend on how you enabled the imagemagick extension: as a separate action, or as an after_filter for your own action.
Returns an image tag for the image with the given +filename, which will be rendered with the given ImageMagick commands.
filename_or_params should point to an image in the directory you specified with imagemagick_for. You can have subdirectories, in that case you prepend the name of the subdirectory to filename_or_params
commands can be a String of commands, separated by plus signs:
"resize(100x100)+flop+rotate(45)"
or, commands can be an Array of command strings and command+argument arrays:
[ ["resize", "100x100"], "flop", ["rotate", "45"] ]
The options will be forwarded to the normal image_tag method (and will be used as the html attributes.) The only exception is this option:
| :controller: | the name of the controller in which the ImageMagick macro is activated. It defaults to the current controller, but you can specify something else. |
Examples:
<%= imagemagick_tag "presentation.png", "resize(100x100)+flop", :alt=>"Presentation" %> <%= imagemagick_tag "presentation.png", "equalize", :controller=>"photo", :alt=>"Presentation" %> <%= imagemagick_tag "presentation.png", "equalize" %> <%= imagemagick_tag "rails/presentation.png", "equalize" %>
Returns an image tag for the action with the parameters in filename_or_params (in url_form format). The result of that action will be rendered with the given ImageMagick commands.
filename_or_params should be the url_for options hash that points to the action that renders the image. You can use any parameters your action need.
commands can be a String of commands, separated by plus signs:
"resize(100x100)+flop+rotate(45)"
or, commands can be an Array of command strings and command+argument arrays:
[ ["resize", "100x100"], "flop", ["rotate", "45"] ]
The options will be forwarded to the normal image_tag method (and will be used as the html attributes.)
Instead of provinding a separate commands argument, you can also specify the commands as the :commands parameters in the url_for hash. (If you have renamed :commands in the configuration, you should use the new name instead.)
Examples:
<%= imagemagick_tag({:action=>'display_image', :id=>10}, 'resize(100x100)+flop', {:alt=>"Presentation"}) %>
<%= imagemagick_tag({:controller=>'photo', :action=>'display_image', :id=>10}, 'resize(100x100)+flop', {:alt=>"Presentation"}) %>
<%= imagemagick_tag :action=>'display_image', :id=>10, :user=>10, :other_param=>'abc', :commands=>'equalize' %>