<?xml version="1.0" encoding="utf-8"?><?xml-stylesheet title="XSL formatting" type="text/xsl" href="https://uname.pingveno.net/blog/index.php/feed/rss2/xslt" ?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title># uname -a - Mot-clé - effect</title>
    <link>https://uname.pingveno.net/blog/index.php/</link>
    <atom:link href="https://uname.pingveno.net/blog/index.php/feed/tag/effect/rss2" rel="self" type="application/rss+xml" />
    <description>Le blog de uname.pingveno.net</description>
    <language>fr</language>
    <pubDate>Tue, 18 Aug 2026 13:46:21 +0200</pubDate>
    <copyright>Mathieu Pellegrin</copyright>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <generator>Dotclear</generator>
          <item>
        <title>Drupal 7 : create your own image effect for use in image styles</title>
        <link>https://uname.pingveno.net/blog/index.php/post/2015/02/25/Drupal-7-%3A-create-your-own-image-effect-for-use-in-image-styles</link>
        <guid isPermaLink="false">urn:md5:07800b84eeef05debd24db6354b32e72</guid>
        <pubDate>Wed, 25 Feb 2015 18:56:00 +0100</pubDate>
        <dc:creator>Mathieu</dc:creator>
                  <category>Hacks</category>
                          <category>drupal</category>
                  <category>drupal 7</category>
                  <category>effect</category>
                  <category>image</category>
                  <category>module</category>
                  <category>php</category>
                  <category>style</category>
                <description>&lt;p&gt;Drupal comes with many predefined effects, you can combine them in image styles to get the picture you want. But what if you have to make your own effect&amp;#160;? Here is how.&lt;/p&gt;          &lt;h3&gt;Step 1&amp;#160;: create a module&lt;/h3&gt;

&lt;p&gt;If you are a drupal developer, you should know how to make a module. Okay, I am lazy too&amp;#160;:&lt;/p&gt;

&lt;p&gt;myeffect.info&amp;#160;:&lt;/p&gt;

&lt;pre&gt;
name = My Effect
description = &quot;My wonderful border effect&quot;
core = 7.x
dependencies[] = image
files[] = myeffect.module
package = Media&lt;/pre&gt;

&lt;h3&gt;Step 2&amp;#160;: declare your effect&lt;/h3&gt;

&lt;p&gt;Implement hook_image_effect_info&amp;#160;:&lt;/p&gt;

&lt;pre&gt;
function myeffect_image_effect_info() {
  $effects = array(
    'myeffect_image_border' =&amp;gt; array(
      'label' =&amp;gt; t('My Effect - Border'),
      'help' =&amp;gt; t('Add border to an image'),
      'effect callback' =&amp;gt; '_myeffect_image_border_effect',
// Let's make things simpler...
//      'form callback' =&amp;gt; '_myeffect_image_border_form',
//      'summary theme' =&amp;gt; '_myeffect_image_border_summary',
    ),
  );
  return $effects;
}&lt;/pre&gt;

&lt;h3&gt;Step 3&amp;#160;: write the callback&lt;/h3&gt;

&lt;pre&gt;
function _myeffect_image_border_effect(&amp;amp;$image, $data) {
  if (!_myeffect_image_border($image, $data)) {
    watchdog('image', 'Image add border failed using the %toolkit toolkit on %path (%mimetype)', array(
      '%toolkit' =&amp;gt; $image-&amp;gt;toolkit,
      '%path' =&amp;gt; $image-&amp;gt;source,
      '%mimetype' =&amp;gt; $image-&amp;gt;info['mime_type'],
    ), WATCHDOG_ERROR);
    return FALSE;
  }
  return TRUE;
}

function _myeffect_image_border(stdClass $image, $data) {
  if ($image-&amp;gt;toolkit == 'gd') {
    $params = array($image, $data);
    return call_user_func_array('_myeffect_gd_border', $params);
  } else {
    watchdog('image', 'The selected image handling toolkit %toolkit can not correctly process %function.', array(
      '%toolkit' =&amp;gt; $image-&amp;gt;toolkit,
      '%function' =&amp;gt; $function,
    ), WATCHDOG_ERROR);
    return FALSE;
  }
}&lt;/pre&gt;

&lt;h3&gt;Step 4&amp;#160;: make your effect&amp;#160;!&lt;/h3&gt;

&lt;pre&gt;
function _myeffect_gd_border(stdClass $image, $data) {

  $width = $image-&amp;gt;info['width'];
  $height = $image-&amp;gt;info['height'];

  // Note : source image is in $image-&amp;gt;resource
  $dst = imagecreatetruecolor($width, $height);

...

  // Update image object.
  $image-&amp;gt;resource = $dst;
  $image-&amp;gt;info['width'] = $width;
  $image-&amp;gt;info['height'] = $height;

  return TRUE;
}&lt;/pre&gt;

&lt;h3&gt;Source&lt;/h3&gt;

&lt;p&gt;The content of this article is widely based on the module &lt;a href=&quot;https://www.drupal.org/project/iek&quot; hreflang=&quot;en&quot;&gt;Image Effect Kit&lt;/a&gt;, you can download and read it for a more complete example.&lt;/p&gt;</description>
        
              </item>
      </channel>
</rss>
