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 Robin S
      Repeater Images
      Adds options to modify Repeater fields to make them convenient for "page-per-image" usage. Using a page-per-image approach allows for additional fields to be associated with each image, to record things such as photographer, date, license, links, etc.
      When Repeater Images is enabled for a Repeater field the module changes the appearance of the Repeater inputfield to be similar (but not identical) to an Images field. The collapsed view shows a thumbnail for each Repeater item, and items can be expanded for field editing.
      Screencast

      Installation
      Install the Repeater Images module.
      Setup
      Create an image field to use in the Repeater field. Recommended settings for the image field are "Maximum files allowed" set to 1 and "Formatted value" set to "Single item (null if empty)". Create a Repeater field. Add the image field to the Repeater. If you want additional fields in the Repeater create and add these also. Repeater Images configuration
      Tick the "Activate Repeater Images for this Repeater field" checkbox. In the "Image field within Repeater" dropdown select the single image field. You must save the Repeater field settings to see any newly added Image fields in the dropdown. Adjust the image thumbnail height if you want (unlike the core Images field there is no slider to change thumbnail height within Page Edit). Note: the depth option for Repeater fields is not compatible with the Repeater Images module.
      Image uploads feature
      There is a checkbox to activate image uploads. This feature allows users to quickly and easily add images to the Repeater Images field by uploading them to an adjacent "upload" field.
      To use this feature you must add the image field selected in the Repeater Images config to the template of the page containing the Repeater Images field - immediately above or below the Repeater Images field would be a good position.
      It's recommended to set the label for this field in template context to "Upload images" or similar, and set the visibility of the field to "Closed" so that it takes up less room when it's not being used. Note that when you drag images to a closed Images field it will automatically open. You don't need to worry about the "Maximum files allowed" setting because the Repeater Images module overrides this for the upload field.
      New Repeater items will be created from the images uploaded to the upload field when the page is saved. The user can add descriptions and tags to the images while they are still in the upload field and these will be retained in the Repeater items. Images are automatically deleted from the upload field when the page is saved.
      Tips
      The "Use accordion mode?" option in the Repeater field settings is useful for keeping the inputfield compact, with only one image item open for editing at a time. The "Repeater item labels" setting determines what is shown in the thumbnail overlay on hover. Example for an image field named "image": {image.basename} ({image.width}x{image.height})  
      https://github.com/Toutouwai/RepeaterImages
      https://modules.processwire.com/modules/repeater-images/
    • By EyeDentify
      Hello There Guys.

      I am in the process of getting into making my first modules for PW and i had a question for you PHP and PW gurus in here.

      I was wondering how i could use an external library, lets say TwitterOAuth in my PW module.
      Link to library
      https://twitteroauth.com/

      Would the code below be correct or how would i go about this:
      <?PHP namespace ProcessWire; /* load the TwitterOAuth library from my Module folder */ require "twitteroauth/autoload.php"; use Abraham\TwitterOAuth\TwitterOAuth; class EyeTwitter extends WireData,TwitterOAuth implements Module { /* vars */ protected $twConnection; /* extend parent TwitterOAuth contructor $connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $access_token, $access_token_secret); */ public function myTwitterConnection ($consumer_key, $consumer_secret, $access_token, $access_token_secret) { /* save the connection for use later */ $this->twConnection = TwitterOAuth::__construct($consumer_key, $consumer_secret, $access_token, $access_token_secret); } } ?> Am i on the right trail here or i am barking up the wrong tree?
      I don´t need a complete solution, i just wonder if i am including the external library the right way.
      If not, then give me a few hint´s and i will figure it out.

      Thanks a bunch.

      /EyeDentify
    • By dimitrios
      Hello,
      this module can publish content of a Processwire page on a Facebook page, triggered by saving the Processwire page.
      To set it up, configure the module with a Facebook app ID, secret and a Page ID. Following is additional configuration on Facebook for developers:
      Minimum Required Facebook App configuration:
      on Settings -> Basics, provide the App Domains, provide the Site URL, on Settings -> Advanced, set the API version (has been tested up to v3.3), add Product: Facebook Login, on Facebook Login -> Settings, set Client OAuth Login: Yes, set Web OAuth Login: Yes, set Enforce HTTPS: Yes, add "http://www.example.com/processwire/page/" to field Valid OAuth Redirect URIs. This module is configurable as follows:
      Templates: posts can take place only for pages with the defined templates. On/Off switch: specify a checkbox field that will not allow the post if checked. Specify a message and/or an image for the post.
      Usage
      edit the desired PW page and save; it will post right after the initial Facebook log in and permission granting. After that, an access token is kept.
       
      Download
      PW module directory: http://modules.processwire.com/modules/auto-fb-post/ Github: https://github.com/kastrind/AutoFbPost   Note: Facebook SDK for PHP is utilized.


    • By kongondo
      FieldtypeRuntimeMarkup and InputfieldRuntimeMarkup
       
      Modules Directory: http://modules.processwire.com/modules/fieldtype-runtime-markup/
      GitHub: https://github.com/kongondo/FieldtypeRuntimeMarkup
      As of 11 May 2019 ProcessWire versions earlier than 3.x are not supported
      This module allows for custom markup to be dynamically (PHP) generated and output within a page's edit screen (in Admin).
       
      The value for the fieldtype is generated at runtime. No data is saved in the database. The accompanying InputfieldRuntimeMarkup is only used to render/display the markup in the page edit screen.
       
      The field's value is accessible from the ProcessWire API in the frontend like any other field, i.e. it has access to $page and $pages.
       
      The module was commissioned/sponsored by @Valan. Although there's certainly other ways to achieve what this module does, it offers a dynamic and flexible alternative to generating your own markup in a page's edit screen whilst also allowing access to that markup in the frontend. Thanks Valan!
       
      Warning/Consideration
      Although access to ProcessWire's Fields' admin pages is only available to Superusers, this Fieldtype will evaluate and run the custom PHP Code entered and saved in the field's settings (Details tab). Utmost care should therefore be taken in making sure your code does not perform any CRUD operations!! (unless of course that's intentional) The value for this fieldtype is generated at runtime and thus no data is stored in the database. This means that you cannot directly query a RuntimeMarkup field from $pages->find(). Usage and API
       
      Backend
      Enter your custom PHP snippet in the Details tab of your field (it is RECOMMENDED though that you use wireRenderFile() instead. See example below). Your code can be as simple or as complicated as you want as long as in the end you return a value that is not an array or an object or anything other than a string/integer.
       
      FieldtypeRuntimeMarkup has access to $page (the current page being edited/viewed) and $pages. 
       
      A very simple example.
      return 'Hello'; Simple example.
      return $page->title; Simple example with markup.
      return '<h2>' . $page->title . '</h2>'; Another simple example with markup.
      $out = '<h1>hello '; $out .= $page->title; $out .= '</h1>'; return $out; A more advanced example.
      $p = $pages->get('/about-us/')->child('sort=random'); return '<p>' . $p->title . '</p>'; An even more complex example.
      $str =''; if($page->name == 'about-us') { $p = $page->children->last(); $str = "<h2><a href='{$p->url}'>{$p->title}</a></h2>"; } else { $str = "<h2><a href='{$page->url}'>{$page->title}</a></h2>"; } return $str; Rather than type your code directly in the Details tab of the field, it is highly recommended that you placed all your code in an external file and call that file using the core wireRenderFile() method. Taking this approach means you will be able to edit your code in your favourite text editor. It also means you will be able to type more text without having to scroll. Editing the file is also easier than editing the field. To use this approach, simply do:
      return wireRenderFile('name-of-file');// file will be in /site/templates/ If using ProcessWire 3.x, you will need to use namespace as follows:
      return ProcessWire\wireRenderFile('name-of-file'); How to access the value of RuntimeMarkup in the frontend (our field is called 'runtime_markup')
       
      Access the field on the current page (just like any other field)
      echo $page->runtime_markup; Access the field on another page
      echo $pages->get('/about-us/')->runtime_markup; Screenshots
       
      Backend
       

       

       
      Frontend
       

×
×
  • Create New...