horst Posted November 18, 2015 Author Share Posted November 18, 2015 Thanks for the info and the module! I will try it out when I have a bit more time. So, you influence filesizes with specifying the quality level (0-100). You can set it sitewide in the config.php (default is 90) or you can pass it individually in an options array everywhere on API level. Is the last file in your screenshot created via GD, and what setting for quality have you used? Link to comment Share on other sites More sharing options...
ukyo Posted November 18, 2015 Share Posted November 18, 2015 Both (with your module and with my module) used default quality option "90" and GD library used. Didn't test "Imagick" Library yet but it must work, if extension is installed. I checked difference between "Imagick" and "GD" there not much difference about file sizes. Comments about "Imagick" quality is much better for compression than "GD". 1 Link to comment Share on other sites More sharing options...
Beluga Posted January 26, 2016 Share Posted January 26, 2016 A little tip that non-advanced users like me might appreciate: foreach ($galleryimages as $image) { ini_set('max_execution_time', 1200); // this line resets the timer for max_execution_time with every loop. $infoarray = $image->pim2Load('f-')->getImageInfo(); $thumb = $image->pim2Load('t-')->width(200)->pimSave()->url; $full = $image->url; if ($infoarray['width'] > 2000) { $full = $image->pim2Load('f-')->width(2000)->pimSave()->url; } echo "<div class='galleryimage'><img class='jslghtbx-thmb' src='$thumb' data-jslghtbx='$full' data-jslghtbx-group='galtsu' data-jslghtbx-caption='$image->description'></img></div>"; } That code will skip resizing with PIM, if the original width is not over 2000px. Link to comment Share on other sites More sharing options...
bernhard Posted March 1, 2016 Share Posted March 1, 2016 awesome module horst, thank you very much! think i found a little bug? // config.php $config->imageManipulatorOptions = array( 'outputFormat' => 'png' ); // template $image = $image->pim2Load('sticker')->grayscale()->pimSave(); does create a jpg. $image = $image->pim2Load('sticker')->grayscale()->setOutputFormat('png')->pimSave(); does create a png (that's what i wanted, but setting it in config.php seems not to work) Link to comment Share on other sites More sharing options...
horst Posted March 1, 2016 Author Share Posted March 1, 2016 It is not intended to be set as global / default option sitewide. You definitly need to set it with every request. The default behave is, if you do not explicitly define an outputformat, the outputformat is the same as the inputformat: jpg => jpg jpg => setOutputformat('png') => png So, it is not a bug in the module, but a "bug" in the description here. I will update the description. Thanks for pointing out, @BernhardB. 2 Link to comment Share on other sites More sharing options...
bernhard Posted March 1, 2016 Share Posted March 1, 2016 don't know how hard that would be to implement but in my case it would be better if it was configurable globally. maybe if it is NOT set it will stay "auto" like it is now, but if it is set to eg "png" it will use this as default? definitely no big issue - just a suggestion for a very very very small improvement 1 Link to comment Share on other sites More sharing options...
Torsten Baldes Posted March 16, 2016 Share Posted March 16, 2016 @horst would it be possible to achieve a stronger blur (like this image on the right: http://codepen.io/tobaco/pen/ZWBRwX)%C2'> effect then the currently available (blur or smooth) with PIM and GD? i tried various things (playing with transparency and overlaying or multiple blur calls). the first attempt looks really cheap and the second is to ressource hungry to work for the desired blur effect. i know that imageMagick can do this, but unfortunately that's no option here. :-/ thanks! Link to comment Share on other sites More sharing options...
netcarver Posted March 17, 2016 Share Posted March 17, 2016 @Horst Thank you for this module. I've hit the anti-aliasing problem in watermarkText() you mentioned back on page 2 of this thread (I'm using PHP7). This fixed the issue for me... if (function_exists('imageantialias')) { @imageantialias($im1, FALSE); } 3 Link to comment Share on other sites More sharing options...
horst Posted March 17, 2016 Author Share Posted March 17, 2016 Thank you for this module. I've hit the anti-aliasing problem in watermarkText() you mentioned back on page 2 of this thread (I'm using PHP7). This fixed the issue for me... if (function_exists('imageantialias')) { @imageantialias($im1, FALSE); } Thank you for the good news! (and the fix) 1 Link to comment Share on other sites More sharing options...
Frank Vèssia Posted March 30, 2016 Share Posted March 30, 2016 Hi,I don't know if depends of PW devns 3.0.10 or something in my code but this $watermark = $config->paths->root.$config->site_cdn."wm.png"; $options = array('outputFormat'=>'jpg','quality'=>70); // first method $pic->image->first()->pim2Load('wtm')->setOptions($options)->watermarkLogo($watermark,'SE',8)->pimSave(); // another try $pixelateVersion = $pic->image->first()->pim2Load('pxtd',true)->setOptions($options)->width(700)->pixelate(30)->pimSave(); $pic->image->add($pixelateVersion); simply overwrites the first image file without creating a copy with prefix as expected.I copied this code from another pw installation (2.6) Link to comment Share on other sites More sharing options...
horst Posted March 31, 2016 Author Share Posted March 31, 2016 There are no prefixes supported in PW 3. (but suffixes) I assume, you use Pim1? If so, you need to switch to Pim2. Have a read here: https://processwire.com/talk/topic/9982-page-image-manipulator-2/ If this is not the case, please post again. Link to comment Share on other sites More sharing options...
Frank Vèssia Posted March 31, 2016 Share Posted March 31, 2016 I'm using pim2 as you can see from the code "->pim2Load". In any case (prefix or suffix) the original image has been replaced.Anything to look in PW, some config options can interferes with the module? Link to comment Share on other sites More sharing options...
horst Posted March 31, 2016 Author Share Posted March 31, 2016 (edited) I'm using pim2 as you can see from the code "->pim2Load". Oh, sorry! --- --- --- Is $pic->image an imagefield set to hold multiple images or only one image? Please, can you, for debug purposes, output the filename of the variation, instead of adding it to the imagefield? $options = array('outputFormat'=>'jpg','quality'=>70); $originalImage = $pic->image->first(); $pixelateVersion = $originalImage->pim2Load('pxtd',true)->setOptions($options)->width(700)->pixelate(30)->pimSave(); echo "<p>{$originalImage->filename}<br />{$pixelateVersion->filename}</p>"; Edited March 31, 2016 by horst Link to comment Share on other sites More sharing options...
Frank Vèssia Posted March 31, 2016 Share Posted March 31, 2016 the image field holds multiple images, that was my first thought the echo outputs the same filename, there is no variation, that's the problem, it replaces the original image Link to comment Share on other sites More sharing options...
horst Posted March 31, 2016 Author Share Posted March 31, 2016 Hhm, for me it is working: D:/ProcessWire/PW-DEV/pw30/htdocs/site/assets/files/1/nikon2208.jpg D:/ProcessWire/PW-DEV/pw30/htdocs/site/assets/files/1/nikon2208.-pim2-pxtd.jpg I used PW 3.0.10 You may look at other modules that work with files and images. Maybe you can create a siteprofile with the exporter or are you able to temporarily disable site-modules in the original site? So, your code is working, the Pim2 is working, but not in your setup. If possible, I would disable all (autoload and file/image-related) modules, and try if it works then. If yes, enable one module after the other, and check if it is working or if it breaks again. Or the other way round: disable one module, check if it changes, if not disable the next one, ..., ... YOu may also first have a look to the Hooks-Section of the Debug Mode Tools in the admin footer to get an overview which modules hook into what, maybe this way you can spot primarily candidates very fast. It all depends on your setup I believe. 1 Link to comment Share on other sites More sharing options...
iNoize Posted June 29, 2016 Share Posted June 29, 2016 Hello, where can I get the PIM2 Module ? currently used with pw. 3.0.23 from the ModulesManager cant find the pim2 Link the one on the first side doesnt work for me. And is it on the Memory only ? If i check the variations the is see something like this. http://prntscr.com/bmm8aa The first two images are generated with the PW Api. If its only in the memory it couldnt be used with many of images on one site ? Tnx Link to comment Share on other sites More sharing options...
horst Posted June 29, 2016 Author Share Posted June 29, 2016 simply go to the modules directory, you find it directly on the first page under "User Favorites", the second item. Or here. Your other questions I don't understand. ?? In the modules package are a module pim1 and a module pim2. If you use a PW version greater than 2.5.11, please do not install pim1, install pim2! That's all. Hope this helps? Link to comment Share on other sites More sharing options...
iNoize Posted June 29, 2016 Share Posted June 29, 2016 Thaks for your answer I already installed the module from modules manager. Now I also installed the second version. Should i leave the first od better remove ? Link to comment Share on other sites More sharing options...
horst Posted June 29, 2016 Author Share Posted June 29, 2016 Yes, please only use the second one. Best is to uninstall the first one. The first one is obsolete, as it only supports the older image variations naming convention, and not the new one, introduced in PW 2.5.11. 1 Link to comment Share on other sites More sharing options...
POWERFULHORSE Posted August 31, 2016 Share Posted August 31, 2016 Is it possible to invert a PNG with transparency with PIM? I have an image which is essentially a white (255,255,255) shape over a transparent background, and I would like to make the white shape black whilst maintaining the transparent area. Link to comment Share on other sites More sharing options...
horst Posted September 1, 2016 Author Share Posted September 1, 2016 I don't know. Have you tried it with negate ? What is the result? Link to comment Share on other sites More sharing options...
POWERFULHORSE Posted September 1, 2016 Share Posted September 1, 2016 Sorry, I should have mentioned that was the method I was using. No luck unfortunately. It seems that neither negate nor colorize preserve transparency. Link to comment Share on other sites More sharing options...
horst Posted September 1, 2016 Author Share Posted September 1, 2016 Uhm, - doesn't sound good. Transparency has made problems all the last twenty years with GD. I'm not sure, but maybe I have read something about that they have updated their Lib to support it. Maybe the version what is bundled with PHP-7 does support it now (?) <- Not sure on this. Other than that, I believe we can do nothing. (Using any function would result into the same) Link to comment Share on other sites More sharing options...
Robin S Posted September 2, 2016 Share Posted September 2, 2016 @POWERFULHORSE, if you have Imagick installed on your server you can try a slightly modified version (below) of the function I introduced in this post. // ImageMagick effects function imagickal($imagePath, $format, $method, array $arguments) { $path_parts = pathinfo($imagePath); $dirname = $path_parts['dirname'] . '/'; $filename = $path_parts['filename']; $mod = $method . '-' . implode($arguments, '-'); $mod = wire('sanitizer')->filename($mod, true); $savename = "{$dirname}{$filename}_{$mod}.{$format}"; if (!file_exists($_SERVER['DOCUMENT_ROOT'] . $savename)) { $image = new Imagick($_SERVER['DOCUMENT_ROOT'] . $imagePath); call_user_func_array([$image, $method], $arguments); $image->setImageFormat($format); $image->writeImage($_SERVER['DOCUMENT_ROOT'] . $savename); } return $savename; } I tested it as follows... $orig = "/site/templates/images/transparent.png"; $after = imagickal($orig, 'png', 'negateImage', [false]); echo "<img src='$orig'>"; echo "<img src='$after'>"; ...and the results... 6 Link to comment Share on other sites More sharing options...
POWERFULHORSE Posted September 5, 2016 Share Posted September 5, 2016 You're a genius @Robin S. Thank you! 1 Link to comment Share on other sites More sharing options...
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