Jump to content
horst

Page Image Manipulator 1

Recommended Posts

Ok I have it corrected but still it doesn't work. No error, no new image created.

$p = wire("pages")->get(1111);
echo $p->image->url;
$img = $p->image;
$pim = $img->pimLoad("bright")->contrast(100)->brightness(100)->pimSave();
echo "<img src='$pim->url'/>";
 

Share this post


Link to post
Share on other sites

Ok I have it corrected but still it doesn't work. No error, no new image created.

$p = wire("pages")->get(1111);
echo $p->image->url;
$img = $p->image;
$pim = $img->pimLoad("bright")->contrast(100)->brightness(100)->pimSave();
echo "<img src='$pim->url'/>"; 

hhm, very mysterious. When I use your code I get a new image!

I assume you have get the latest version of the module, tried a new install already?

What do you get when you use:

$p = wire("pages")->get(1111);
$img = $p->image;

echo '<p>' . $img->url .'</p>';
echo '<p>' . $img->width(240)->url .'</p>';   // does the imageSizer work with that image?

echo '<pre>';
	var_dump($img->pimLoad("bright")->getImageInfo());  // what is the output here
echo '</pre>';

Share this post


Link to post
Share on other sites

No there's no image created and it silently fails, means code after doing the image doesn't get executed at all.

I tried locally and it works, so it's the server I'm working on... although it's php 5.3 and GD 2...

Share this post


Link to post
Share on other sites

@soma: does the imageSizer work with the images?

$img->width(240) or $img->size()

Share this post


Link to post
Share on other sites

and what is the output from:

var_dump( $img->pimLoad("bright")->getImageInfo() );  // what is the output here

Share this post


Link to post
Share on other sites

It doesn't do anything. :)

Ok strange, now it works, and I only added some echo "test" inside the getPageImageManipulator() and uploaded. 

So I think I got when testing added a exit() there and haven't uploaded the module when removing it. Darn. :) Thanks for your time.

  • Like 1

Share this post


Link to post
Share on other sites

post-100-0-08539200-1376954452_thumb.png

This is kinda fun... 

Q: How could I easily replace the original pageimage keeping same filename?

  • Like 3

Share this post


Link to post
Share on other sites

Q: How could I easily replace the original pageimage keeping same filename?

with a pageimage loaded into the {Pageimage} {Manipulator} you are not able to overwrite the original!

You have to use the {Image} {Manipulator} manually with a filename. Here you can do everything you want, - or the opposite: you alone are fully responsible for _all_ actions, ;-)

$pim = $wire->modules->get('PageImageManipulator')->imLoad($imageFilename, $options);  // here it is used imLoad = image manipulator instead of page image manipulator

If you do not specify an alternate filename or outputFormat with the options array, the sourcefile loaded into the IM is overwritten by default!

Note: if you overwrite your original image, you wipe out all EXIF-data, whereas all IPTC-data is kept!

-------------

Hey Soma, it looks like you are building a visual Photo-Editor based on PW.  cool!

  • Like 1

Share this post


Link to post
Share on other sites

Horst, would you consider adding a resize mode that adds a colored or transparent padding instead of distorting the image? Something like this:

post-88-0-34291900-1376990070_thumb.jpg

post-88-0-46710400-1376990084_thumb.jpg

  • Like 1

Share this post


Link to post
Share on other sites

Greetings,

Horst, would you consider adding a resize mode that adds a colored or transparent padding instead of distorting the image? Something like this:

That would be great!

I can't even count how many client photos I have had to edit manually in this way so they look correct in my galleries.

Thanks,

Matthew

Share this post


Link to post
Share on other sites

Horst, would you consider adding a resize mode that adds a colored or transparent padding instead of distorting the image? Something like this:

attachicon.gifmarquis_interior3_bvnesu_amarelo.jpg

attachicon.gifmarquis_interior3_bvnesu_verde.jpg

Hi diogo, if you believe it or not, I have thought about this allready. And I have something like this in an old image lib of mine. I will look at that code and port it to the IM.

I think best way is to define dimensions of a canvas in that the previous created image is centered. That way one can get only the horizontal or only the the vertical bars, or surrounding ones.

Share this post


Link to post
Share on other sites

Great!

I think it could be even more complex than that. Ideally it would have these options:

  • width
  • height
  • background-color (including the possibility of rgba if possible)
  • x-position
  • y-position

Does it make sense like this?

Share this post


Link to post
Share on other sites

Great!

I think it could be even more complex than that. Ideally it would have these options:

  • width
  • height
  • background-color (including the possibility of rgba if possible)
  • x-position
  • y-position

Does it make sense like this?

@diogo: width & height & BG as rgba is ok!

But for what is x- and y-position?

I have thought one want to center it into the canvas.

If you think it make sence to position out of the center, I think it could be better to use the north, northwest, center, etc position and a $padding (I would prefer in percent), that would be most consistent way with other methods.

What do you think?

Share this post


Link to post
Share on other sites

hoi, there are now two 'unplanned' additions in the Version 0.0.5:
 
canvas($width, $height, $bgcolor, $position, $padding)

  • $width = mixed, associative array with options or integer, mandatory!
  • $height = integer, mandatory if $width is integer!
  • $bgcolor = array with rgb or rgba, - default is 255, 255, 255
  • $position = one out of north, northwest, center, etc, - default is center
  • $padding = integer as percent of canvas length, - default is 0

pw_pim_canvas.jpg
 


unsharpMask($amount=100, $radius=0.5, $threshold=3) // its the same like the method in Photoshop,
credit goes to: Torstein Hønsi for the unsharp mask algorithm (created in 2003 - p h p U n s h a r p M a s k)!


pw_pim_unsharpMask.jpg

..., can create better results than the default stepResize!

  • Like 2

Share this post


Link to post
Share on other sites

Is there a auto level or auto adjust function in gd like with imagemagick?

Share this post


Link to post
Share on other sites

So there's a ton of functions and filter but auto-levels http://www.imagemagick.org/script/command-line-options.php#auto-level there's nothing in GD? ... :D

Other then in imagemagick, i don't see a ton of functions and filters in there :D

I think to autoadjust something there is always a portion of guessing with it - or 'out-rider' pixels that screw up or down the autoadjusted result into false directions.

I never use such tools without a manually visually control. Also with captureOne and photoshop I do not use those with batch editing.

Share this post


Link to post
Share on other sites

Hi Horst, your plugin is great and the canvas addition is superb ;-)

However ... I have there a little problem with the canvas addition. 

The call of

child->image2->pimLoad('wh',true)->canvas(195,193,array(0,0,0,0.0),"centered",0)->pimSave()->url;

returns me the image with a black border. I want it transparent. Is there something I missed?

TIA

Henning

Share this post


Link to post
Share on other sites

Hi Henning,

I think you have the wrong param for opacity. PHP.net says:

function imagecolorallocatealpha

  param alpha:
      A value between 0 and 127. 0 indicates completely opaque while 127 indicates completely transparent.

Please try with

child->image2->pimLoad('wh', true)->canvas(195, 193, array(0, 0, 0, 127), "centered", 0)->pimSave()->url;

EDIT:

@Henning: I have noticed that the common way to define a rgba color is 0-255 for R, G and B and a float value between 0 and 1 for the alpha channel (opacity). 0 is transparent and 1 is opaque.

I think it is better to use the common way with float 0-1 as param and convert it internally to suite the need of the GD-lib.

The change will go into the module version 0.0.8 and I will release it later this weekend.

Edited by horst
  • Like 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By gebeer
      Although the PW backend is really intuitive, ever so often my clients need some assistance. Be it they are not so tech savvy or they are not working in the backend often.
      For those cases it is nice to make some help videos available to editors. This is what this module does.
      ProcessHelpVideos Module
      A Process module to display help videos for the ProcessWire CMS. It can be used to make help videos (screencasts) available to content editors.
      This module adds a 'Help Videos" section to the ProcessWire backend. The help videos are accessible through an automatically created page in the Admin page tree. You can add your help videos as pages in the page tree. The module adds a hidden page to the page tree that acts as parent page for the help video pages. All necessary fields and templates will be installed automatically. If there are already a CKEditor field and/or a file field for mp4 files installed in the system, the module will use those. Otherwise it will create the necessary fields. Also the necessary templates for the parent help videos page and it's children are created on module install. The module installs a permission process-helpvideos. Every user role that should have access to the help video section, needs this permission. I use the help video approach on quite a few production sites. It is stable so far and well received by site owners/editors. Up until now I installed required fields, templates and pages manually and then added the module. Now I added all this logic to the install method of the module and it should be ready to share.
      The module and further description on how to use it is available on github: https://github.com/gebeer/ProcessHelpVideos
      If you like to give it a try, I am happy to receive your comments/suggestions here.
    • By Robin S
      A module created in response to the topic here:
      Page List Select Multiple Quickly
      Modifies PageListSelectMultiple to allow you to select multiple pages without the tree closing every time you select a page.
      The screencast says it all:

       
      https://github.com/Toutouwai/PageListSelectMultipleQuickly
      https://modules.processwire.com/modules/page-list-select-multiple-quickly/
    • By gebeer
      Hello all,
      sharing my new module FieldtypeImagePicker. It provides a configurable input field for choosing any type of image from a predefined folder.
      The need for it came up because a client had a custom SVG icon set and I wanted the editors to be able to choose an icon in the page editor.
      It can also be used to offer a choice of images that are used site-wide without having to upload them to individual pages.
      There are no image manipulation methods like with the native PW image field.
      Module and full description can be found on github https://github.com/gebeer/FieldtypeImagePicker
      Kudos to @Martijn Geerts. I used his module FieldTypeSelectFile as a base to build upon.
      Here's how the input field looks like in the page editor:

      Hope it can be of use to someone.
      If you like to give it a try, I'm happy to hear your comments or suggestions for improvement. Eventually this will go in the module directory soon, too.
    • By bernhard
      @Sergio asked about the pdf creation process in the showcase thread about my 360° feedback/survey tool and so I went ahead and set my little pdf helper module to public.
      Description from PW Weekly:
       
      Modules Directory: https://modules.processwire.com/modules/rock-pdf/
      Download & Docs: https://github.com/BernhardBaumrock/RockPDF
       
      You can combine it easily with RockReplacer: 
      See also a little showcase of the RockPdf module in this thread:
       
    • By ukyo
      FieldtypeFontIconPicker
      Supported Icon Libraries
      FontAwesome 4.7.0 Uikit 3.0.34 IonicIcons 2.0.1 Cahangelog
      NOTE: Module store data without prefix, you need to add "prefix" when you want to show your icon on front-end, because some of front-end frameworks using font-awesome with different "prefix".
      Module will search site/modules/**/configs/IconPicker.*.php and site/templates/IconPicker.*.php paths for FieldtypeFontIconPicker config files.
      All config files need to return a PHP ARRAY like examples.
      Example config file : create your own icon set.
      File location is site/configs/IconPicker.example.php
      <?php namespace ProcessWire; /** * IconPicker : Custom Icons */ return [ "name" => "my-custom-icons", "title" => "My Custom Icon Set", "version" => "1.0.0", "styles" => array( wire("config")->urls->templates . "dist/css/my-custom-icons.css" ), "scripts" => array( wire("config")->urls->templates . "dist/js/my-custom-icons.js" ), "categorized" => true, "attributes" => array(), "icons" => array( "brand-icons" => array( "title" => "Brand Icons", "icons" => array( "google", "facebook", "twitter", "instagram" ) ), "flag-icons" => array( "title" => "Flag Icons", "icons" => array( "tr", "gb", "us", "it", "de", "nl", "fr" ) ) ) ]; Example config file : use existing and extend it.
      File location is site/configs/IconPicker.altivebir.php
      <?php namespace ProcessWire; /** * IconPicker : Existing & Extend */ $resource = include wire("config")->paths->siteModules . "FieldtypeFontIconPicker/configs/IconPicker.uikit.php"; $url = wire("config")->urls->templates . "dist"; $resource["scripts"] = array_merge($resource["scripts"], ["{$url}/js/Altivebir.Icon.min.js"]); $resource["icons"]["flag-icons"] = [ "title" => "Flag Icons", "icons" => array("tr", "en", "fr", "us", "it", "de") ]; $resource["icons"]["brand-icons"]["icons"] = array_merge($resource["icons"]["brand-icons"]["icons"], array( "altivebir" )); return $resource; After you add your custom config file, you will see your config file on library select box. Library Title (Location Folder Name).

      If your library categorized and if you have categorized icons set like uikit and fontawesome libraries, you will have category limitation options per icon field or leave it empty for allow all categories (default).

      Example : output
      if ($icon = $page->get("iconField")) { echo "<i class='prefix-{$icon}' />"; } MarkupFontIconPicker Usage
      // MarkupFontIconPicker::render(YourIconField=string, Options=array) echo MarkupFontIconPicker::render($page->YourIconField, [ 'prefix' => 'uk-icon-', // Icon class prefix, if you have different prefix, default is : "fa fa-" 'tag' => 'span', // Icon tag default is : "i" 'class' => 'fa-lg', // If you have extra cutom classes, for example : icons sizes, Array or Sting value 'style' => 'your custom styles if you have' // Array or String Value ]); Theme support

      Search support

      Category support

       
×
×
  • Create New...