JFn Posted August 3, 2017 Share Posted August 3, 2017 (edited) Hi Horst, pim2 v0.2.9 running on PW 2.8.62 overwrites the original image instead of making a variation. I'm using the canvas method <img src="<? echo $image->pim2Load('pim')->setQuality(90)->setOutputFormat('png')->canvas(240,160)->pimSave()->httpUrl; ?>"> chears, JFN. Is this thread abandoned?? Edited August 27, 2017 by JFn no reaction Link to comment Share on other sites More sharing options...
Ivan Gretsky Posted October 4, 2017 Share Posted October 4, 2017 Good day, @horst! Was messing with an old site of mine. I did not even remember I used pim2 on this one. And getting to use this powerful tool once again was a pleasure. Thank you for your work! I had to make a overblurred version of an image for a background. So I used smooth(255) about a 10 times in a row. That did the trick, but the code looks kind of ugly. Am I missing some shortcut way to do it in a more beautiful manner? Link to comment Share on other sites More sharing options...
horst Posted October 4, 2017 Author Share Posted October 4, 2017 Hi @Ivan Gretsky, thanks for the nice words. To make an image overblurred, there is only the "blur" and the "smooth" functions. But maybe you can experiment with using "pixelate" before "smooth"? pixelate(2) or pixelate(3) and then smooth(255), (regarding your desription, maybe 2-3 times smooth(255)) Or isn't that what you are asking for? 1 Link to comment Share on other sites More sharing options...
Robin S Posted October 4, 2017 Share Posted October 4, 2017 @Ivan Gretsky, if you have Imagick installed you could use this function I wrote a while back for easy ImageMagick effects: It does quite a nice blur. But now that supporting IE is less of an issue you could also try a CSS filter. 2 Link to comment Share on other sites More sharing options...
Jonathan Lahijani Posted January 18, 2019 Share Posted January 18, 2019 (edited) @horst I filed this bug report a few weeks ago (includes a video of the bug). Any insight as to why it may be re-generating already generated images? https://github.com/horst-n/PageImageManipulator/issues/4 Edited January 18, 2019 by Jonathan Lahijani forgot link Link to comment Share on other sites More sharing options...
horst Posted January 19, 2019 Author Share Posted January 19, 2019 Hi Jonathan, sorry, I completly missed that one. ? Will looking into it next week. ? And thanks for showing the issue by video, what makes it very clear to follow! Link to comment Share on other sites More sharing options...
horst Posted January 20, 2019 Author Share Posted January 20, 2019 @Jonathan Lahijani Hmm, there is no fast fix possible ATM. BUT you may use this code, passing the options array as second param to pim2Load, what works as expected: $image1->pim2Load('i1')->setOptions(['outputFormat'=>'jpg'])->pimSave(); // FAILES (with outputFormat, all other settings work as expected) $image2->pim2Load('i2', ['outputFormat'=>'jpg'])->pimSave(); // works!! Summary: all option settings work in both ways, BUT changing the outputFormat only works correctly when passed as options argument into pim2Load(). (I think it needs a massive rewrite to fix that properly, for that I have no time atm ?) Link to comment Share on other sites More sharing options...
JFn Posted February 17, 2019 Share Posted February 17, 2019 There are serious issues with this module running PW 3.0.123+. Didn't have time to debug properly, but on different sites the pim2load didn't work anymore. Two different examples that didn't work anymore: $img->pim2Load('img_name')->width(640)->grayscale()->setQuality(80)->pimSave()->url; $img->pim2Load('img_name')->setQuality(90)->setOutputFormat('png')->canvas(240,160)->pimSave()->httpUrl; I ended up disabling the module and using core image manipulations (except for the grayscale... it looks much better in color anyway ?) Link to comment Share on other sites More sharing options...
horst Posted May 6, 2019 Author Share Posted May 6, 2019 @JFn I cannot confirm this. I tested with different newer PW versions up to 3.0.131. Everything is working as expected and like with older PW versions. Only thing from your examples that did not work, is to use the ->setOutputFormat(). How to handle this, please read my post directly above yours. Link to comment Share on other sites More sharing options...
Macrura Posted July 8, 2019 Share Posted July 8, 2019 Just a heads up, I'm getting this warning on PHP 7.3.6 : Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /home/zzzzzz/dev/site/assets/cache/FileCompiler/site/modules/PageImageManipulator/ImageManipulator02.class.php on line 525 Link to comment Share on other sites More sharing options...
horst Posted July 8, 2019 Author Share Posted July 8, 2019 @Macrura thanks for the hint. Have you tried to change that continue into break at line 525? Does it solve the Warning? Link to comment Share on other sites More sharing options...
Macrura Posted July 9, 2019 Share Posted July 9, 2019 yes, it solves the warning for sure. On a separate topic – is there anyway to set the color of watermark text? Link to comment Share on other sites More sharing options...
horst Posted July 9, 2019 Author Share Posted July 9, 2019 On 7/9/2019 at 12:25 AM, Macrura said: On a separate topic – is there anyway to set the color of watermark text? Expand Sorry, no. The current text watermark method analyzes the images and decides between white, gray and black in a automated way. The reason behind that is, you can apply text to any images without knowing which colors it includes. 1 Link to comment Share on other sites More sharing options...
gebeer Posted December 5, 2019 Share Posted December 5, 2019 I am using this module (v0.2.9) to generate low quality previews for use with lazysizes js using following code $imgLow = $img->pim2Load('lowq', true)->setOptions(['quality' => 20])->pixelate(3)->smooth(255)->pimSave(); This is working fine but I quite frequently get a warning: PHP Warning: rename(/home/m1698/Sites/processwire/site/assets/files/14172/p1010866_geschnitten-1.780x0-pim2-lowq.jpg.tmp,/home/m1698/Sites/processwire/site/assets/files/14172/p1010866_geschnitten-1.780x0-pim2-lowq.jpg): No such file or directory in /home/m1698/Sites/processwire/site/assets/cache/FileCompiler/site/modules/PageImageManipulator/ImageManipulator02.class.php:715 It seems that the warning is thrown by rename() because it is being executed on a non existing file ($dest). Somehow $dest must have been deleted. But strange enough, the renamed file exists. So the rename operation seems to have been run successfully. Any idea what might be causing this? Link to comment Share on other sites More sharing options...
eydun Posted February 5, 2020 Share Posted February 5, 2020 Thank you for this great module. In the log I find multiple of these exceptions: Error when trying to resize watermarkLogo to fit to the MemoryImage. (in /site/assets/cache/FileCompiler/site/modules/PageImageManipulator/ImageManipulator02.class.php line 1986) My guess is that some of the images that I am trying to resize are too large (but I am not sure). Any suggestion how to fix this, so I can avoid fatal exceptions? Link to comment Share on other sites More sharing options...
horst Posted February 5, 2020 Author Share Posted February 5, 2020 On 2/5/2020 at 10:41 AM, eydun said: My guess is that some of the images that I am trying to resize are too large (but I am not sure). Expand Some infos may help. How are the dimensions of the images (orig images and the watermark image) How much is the dedicated memory for PHP on your server / account? Link to comment Share on other sites More sharing options...
ak1001 Posted February 5, 2020 Share Posted February 5, 2020 ProcessWire 3.0.98 Pageimage Manipulator 2 0.2.9 Some files(?) put pim2 in endless loop . Loop in ImageManipulator02.class.php : public function __construct($entryItem=null, $options=array(), $bypassOperations=false) { // version check module == class $m = wire('modules')->get('PageImageManipulator02')->getModuleInfo(); $m = preg_replace('/(\d)(?=\d)/', '$1.', str_pad("{$m['version']}", 3, "0", STR_PAD_LEFT)); $c = preg_replace('/(\d)(?=\d)/', '$1.', str_pad("{$this->version}", 3, "0", STR_PAD_LEFT)); if(!version_compare($m, $c, '=')) { throw new WireException("The versions of Module PageImageManipulator02 ($m) and it dependency classfile ImageManipulator02 ($c) are inconsist ent!)"); return; } $this->bypassOperations = true===$bypassOperations ? true : false; // validate PageImage, FileImage, MemoryImage if($entryItem instanceof Pageimage) { $this->pageimage = $entryItem; $this->entryItem = 'page'; $this->filename = $entryItem->filename; $this->isOriginal = $entryItem->original===NULL ? true : false; if(!$this->isOriginal) { // traversing up 'til reaching root reference $this->originalImage = $entryItem->original; while(null !== $this->originalImage->original) { // !!!!!!!!!!!! ENDLESS LOOP HERE !!!!!!!!!!!!!!!!!!!!!!! $reference = $this->originalImage->original; $this->originalImage = $reference; } } } 2 Link to comment Share on other sites More sharing options...
eydun Posted February 5, 2020 Share Posted February 5, 2020 Thanks for the replies. I use PW 3.0.148 and PIM2 0.2.9. Here is my code: $imgWidth = 255; $imgHeight = 312; $imgPadding = 5; $image->pim2Load($product->title)->setOutputFormat('png')->canvas($imgWidth, $imgHeight, array(255, 255, 255, 0) ,'center', $imgPadding)->pimSave(); Actually @ak1001 suggestion of a endless loop, sounds more plausible than it is caused by a too large image. I use a function to selected random images to display, so currently I do not know which source-images are causing the exception. Link to comment Share on other sites More sharing options...
ak1001 Posted February 5, 2020 Share Posted February 5, 2020 Investigating further, in my case problem i think with some file names. For example one page with three images break down on image named 30x30.jpg. I think processwire thinks that it is a variation image forewer. mysql> select pages_id, data, sort from field_tovarimages where pages_id = 9771; +----------+--------------+------+ | pages_id | data | sort | +----------+--------------+------+ | 9771 | 30_belyi.jpg | 0 | | 9771 | 19480.jpg | 1 | | 9771 | 30x30.jpg | 2 | +----------+--------------+------+ 3 rows in set (0.00 sec) So in pim $this->originalImage == $this->originalImage->original and it makes loop ? 1 Link to comment Share on other sites More sharing options...
ak1001 Posted February 5, 2020 Share Posted February 5, 2020 So, public function ___isVariation in class Pageimage have a regexp $re1 = '/^' .. '(\d+)x(\d+)' .> // 50x50 '([pd]\d+x\d+|[a-z]{1,2})?' . <>// nw or p30x40 or d30x40 '(?:-([-_a-z0-9]+))?' . // -suffix1 or -suffix1-suffix2, etc. '\.' . $this->ext() . <> // .jpg '$/'; that will match names like 30x30.jpg and always says this is a variation image. And this will cause the pim go in endless loop. Don't know is there some consequnces for processwire, seems only pim react abnormally. I will rename all images for now, and will ask users to not use such type names, but some prevention methods must be used i think 1 Link to comment Share on other sites More sharing options...
horst Posted February 11, 2020 Author Share Posted February 11, 2020 Hi @ak1001, many thanks for your investigations. Please can you provide me with some informations, so that I can test it locally here, and try to update the ___isVariation stuff to fit with recent PW versions? (When pim was build, we don't have had imge-rendering-engines and the image structures as it is today. We only have had the imagesizer.php and the pageimage.php, where I copy pasted that method from.) Which version of PW are you using: Do you use Pim1 or Pim2: Which module version of Pim: What is the exact full URL of the image(s) in question: Link to comment Share on other sites More sharing options...
ak1001 Posted February 13, 2020 Share Posted February 13, 2020 On 2/11/2020 at 12:54 PM, horst said: Hi @ak1001, many thanks for your investigations. Please can you provide me with some informations Expand Hi @horstProcessWire 3.0.98Pageimage Manipulator 2 0.2.9 exact urls something like : site/assets/files/9771/30x30.jpg pim image : site/assets/files/9771/30x30.-pim2-wm3.jpg Also i was lazy to rename images so i just count loops in PageImageManipulator02.class.php // Construct & Destruct the ImageManipulator02 for a single image public function __construct($entryItem=null, $options=array(), $bypassOperations=false) { ... if(!$this->isOriginal) { // traversing up 'til reaching root reference $this->originalImage = $entryItem->original; $countloop = 0; while(null !== $this->originalImage->original) { $countloop++; $reference = $this->originalImage->original; $this->originalImage = $reference; if($countloop > 5) { error_log("---- ImageManipulator02 loop! ".__LINE__); error_log("---- loop filename= ".$this->filename .", ".__LINE__); break; } } } ... 1 Link to comment Share on other sites More sharing options...
Crowdland Technology Posted June 16, 2020 Share Posted June 16, 2020 Hi! I just found a problem adding a watermar when 2 different images have the same name but the extensions are jpg and jpeg the result is only one image. I fixed it commenting lines 554 to 556 on ImageManipulator02.class.php file. Eg: "photo1.jpg" and "photo1.jpeg" foreach ($images as $img){ $img->pim2Load("wtmd", true)->height(480)->watermarkLogo($watermark, $position = 'center', $padding = 2)->pimSave()->httpUrl; } // The result is photo1.jpg 1 Link to comment Share on other sites More sharing options...
horst Posted June 16, 2020 Author Share Posted June 16, 2020 On 6/16/2020 at 4:09 PM, Crowdland Technology said: Hi! I just found a problem adding a watermar when 2 different images have the same name but the extensions are jpg and jpeg the result is only one image. Expand @Crowdland Technology Many thanks. I have fixed it in the Github Repo. 2 Link to comment Share on other sites More sharing options...
Crowdland Technology Posted June 23, 2020 Share Posted June 23, 2020 Hello @horst me again with problems. Tried to enable webp support and get this error: "Error when trying to save the MemoryImage: we have no Targetfilename!In /site/assets/cache/FileCompiler/site/modules/PageImageManipulator/ImageManipulator02.class.php line 674" I'm using your implementation with the Strategy 1 from this post:https://processwire.com/blog/posts/webp-images-and-more/#strategy-1-automatically-delivering-webp-for-jpg-png-images Everything works until I need to create the image with the watermark. The code for the watermark is: $image_url = $prop->images->eq(0)->pim2Load("wtm",true)->height(480)->watermarkLogo($watermark, $position='center', $padding=2) ->pimSave()->url; Thank you! 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