Soma Posted August 18, 2013 Posted August 18, 2013 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'/>";
horst Posted August 19, 2013 Author Posted August 19, 2013 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>';
Martijn Geerts Posted August 19, 2013 Posted August 19, 2013 Could it be that the image is already created ? To force a recreate use $img->pimLoad("bright", true) I believe.
Soma Posted August 19, 2013 Posted August 19, 2013 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...
horst Posted August 19, 2013 Author Posted August 19, 2013 @soma: does the imageSizer work with the images? $img->width(240) or $img->size()
horst Posted August 19, 2013 Author Posted August 19, 2013 and what is the output from: var_dump( $img->pimLoad("bright")->getImageInfo() ); // what is the output here
Soma Posted August 19, 2013 Posted August 19, 2013 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. 1
Soma Posted August 19, 2013 Posted August 19, 2013 This is kinda fun... Q: How could I easily replace the original pageimage keeping same filename? 3
horst Posted August 20, 2013 Author Posted August 20, 2013 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! 1
diogo Posted August 20, 2013 Posted August 20, 2013 Horst, would you consider adding a resize mode that adds a colored or transparent padding instead of distorting the image? Something like this: 1
MatthewSchenker Posted August 20, 2013 Posted August 20, 2013 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
diogo Posted August 20, 2013 Posted August 20, 2013 Matthew, while this isn't available, have a look at https://launchpad.net/phatch (I linked to it on another post). It's a friendly and very impressive tool. There's no reason to do this manually on a bunch of photos. Here is the documentation: http://photobatch.wikidot.com/
horst Posted August 20, 2013 Author Posted August 20, 2013 Horst, would you consider adding a resize mode that adds a colored or transparent padding instead of distorting the image? Something like this: marquis_interior3_bvnesu_amarelo.jpg marquis_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.
diogo Posted August 20, 2013 Posted August 20, 2013 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?
horst Posted August 20, 2013 Author Posted August 20, 2013 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?
horst Posted August 21, 2013 Author Posted August 21, 2013 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 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)! ..., can create better results than the default stepResize! 2
Soma Posted August 21, 2013 Posted August 21, 2013 Is there a auto level or auto adjust function in gd like with imagemagick?
horst Posted August 21, 2013 Author Posted August 21, 2013 @soma: I think not seriously. (I haven't heard of that.) https://www.google.com/search?q=gd+php+autoadjust%3F
Soma Posted August 21, 2013 Posted August 21, 2013 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? ...
horst Posted August 21, 2013 Author Posted August 21, 2013 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? ... Other then in imagemagick, i don't see a ton of functions and filters in there 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.
hheyne Posted August 29, 2013 Posted August 29, 2013 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
horst Posted August 29, 2013 Author Posted August 29, 2013 (edited) 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 August 31, 2013 by horst 1
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now