Adam Kiss Posted June 15, 2011 Share Posted June 15, 2011 Hello, I have, during building the site changed the imagined size of pictures. Now I found myself with sizes I'm okay with, but I need to re-resize all the images again & with higher quality, because I'm unsatisfied with current quality, caused by (besides other things) by multiple resizes I did in my code. How to do it? Note: I know that Ryan already posted some linux/mac terminal code to clean-up images (thus forcing them to recreate), but I can't fucking find it. Link to comment Share on other sites More sharing options...
ryan Posted June 15, 2011 Share Posted June 15, 2011 Adam, ProcessWire doesn't actually resize your original image, so they should still be in tact. All you have to do is change the resize dimensions and it should be creating the new sizes from the original. But if you want to go in and delete all the extra files for sizes you aren't using anymore, give me a couple days. I'm working on an addition to the FieldtypeImage module for that (an image cache clearing module). 1 Link to comment Share on other sites More sharing options...
Adam Kiss Posted June 15, 2011 Author Share Posted June 15, 2011 Yeah, except I really need to change quality, to have the pictures a little less blurry. And also, I tried a lot of sizes, I want to those resized images gone And I know that PW duplicates pictures, doesn;t resize original... that's why I can't just go to e.g. cache/images and delete stuff – because it's in the same dir as originals, so I would have to be extre careful Isn't there some other way, via API maybe? Link to comment Share on other sites More sharing options...
ryan Posted June 15, 2011 Share Posted June 15, 2011 Well it's actually easy to identify the resized versions because they always follow a common format of filename.123x456.jpg (or substitute another width/height and image extension). Whereas the originals have the same filename, but without the .123x456.jpg part. So the cache clear will be pretty straightforward to write... it'll just look for any images that have that last part and a corresponding filename without it. Then it'll remove all the versions with the .123x456.jpg in the filename. But tracking them down requires a regular expression, so it's not something you can do so easily from your OS (unless you are good with unix file commands... I wouldn't know where to start). So assuming that the full size versions you already have in there are good, then you should be able to resize them to a different dimension. That leaves you with just the extra/unnecessary files you want to delete. Do I have it right? Link to comment Share on other sites More sharing options...
Adam Kiss Posted June 15, 2011 Author Share Posted June 15, 2011 Yeah. But I would welcome any script cleanup, some system-wide button 'clean shit up & recreate resized versions' Link to comment Share on other sites More sharing options...
Adam Kiss Posted June 16, 2011 Author Share Posted June 16, 2011 Not to be nagging, but noone still has answered my question about setting the quality of resized pictures higher Link to comment Share on other sites More sharing options...
seddass Posted June 16, 2011 Share Posted June 16, 2011 via ImageSizer->setQuality() method in /wire/core/ImageSizer.php by default it is 90%. I am curious if the quality of your images will be much better if you change it to 100%. Link to comment Share on other sites More sharing options...
Adam Kiss Posted June 16, 2011 Author Share Posted June 16, 2011 It is, especially when it comes to JPGs with text, which is much sharper (and visually much more appealing) Link to comment Share on other sites More sharing options...
seddass Posted June 16, 2011 Share Posted June 16, 2011 Agreed. Regarding the cleaning of the thumbnails/images created from the uploaded originals... I am using Pageimage->getVariations() and/or removeVariations() and API to loop thru the images. Link to comment Share on other sites More sharing options...
ryan Posted June 20, 2011 Share Posted June 20, 2011 This is an excellent idea. This is what PW uses for cleanup when you delete a page. For a site-wide cache clear of images, this may work very well. But on a really large site, it may be slow (or run out of memory) since it'll involve loading all the pages on the site. So for the image cache clear that I'm writing, it's going to most likely just stick with hunting in the file system and confirming that it's a variation based on the existence of the full size image. Link to comment Share on other sites More sharing options...
douglas81 Posted September 17, 2014 Share Posted September 17, 2014 This is an excellent idea. This is what PW uses for cleanup when you delete a page. For a site-wide cache clear of images, this may work very well. But on a really large site, it may be slow (or run out of memory) since it'll involve loading all the pages on the site. So for the image cache clear that I'm writing, it's going to most likely just stick with hunting in the file system and confirming that it's a variation based on the existence of the full size image. Hey Ryan. I came across this post looking for how to clear image cache. I wonder, did this "image cache clear" module ever come to light? 2 Link to comment Share on other sites More sharing options...
Ivan Gretsky Posted October 4, 2014 Share Posted October 4, 2014 I am here for the same reason. I scaled my images to be 600px high, but did not know upscaling is always on. So I want to re-resize my images from the originals. Is there a wau to do it? Is there a module or some other way to clear the "image cashe"? Link to comment Share on other sites More sharing options...
horst Posted October 5, 2014 Share Posted October 5, 2014 (edited) I have made a module for you (all). I have had allready a routine that iterates through all pages and clears all imagevariations. But this only can be safely used if you have not used images in RTE's from the same page. If you have done so, those cannot be identified and gets deleted too. So please double check that you do not use Pageimages in your RTE fields before running this module. To run it you have to install it, go to its configscreen and check the box to run it. Also there is a second box, always checked by default, that let the script run in testmode. In testmode it doesn't delete the variations but list all found pages and the images count. So, if you really want to delte all ImageVariations sitewide, tipp the box to run the script, untipp the box to run it in testmode and press the submit button. PageimageRemoveVariations.zip EDIT: better use this enhanced module version from @tpr, with configuration for excluding imagefields: enhanced version! Edited September 25, 2016 by horst 8 Link to comment Share on other sites More sharing options...
Ivan Gretsky Posted October 5, 2014 Share Posted October 5, 2014 (edited) This is really great. Functions like it should. If you have time for it, I could suggest a few enhancements for UI: "Cosmetic" - it is not clear how to use it, as the module does not create any menu items; maybe a menu item would be preferable - it is not clear you have to check both boxes to even get a list of images; maybe 1 checkbox (checked by default) will be enough? - i can imagine the list getting really long, so it would not be usable to see it in the message area at the top (maybe make a list below the submit button) - it could be more clear to call the "submit" button something like "clear image cashe" or "clear image variations" "Core" - in joomla and some of its plugins you could see the list of pages and/or images which would be removed while clearing the cashe and check/unckeck them - could be beneficial for this module and make use of something alike page lister - it would be great to have an opportunity to clear image variations from the page admin on per-page or (wild dreams) even per-image basis I am not expecting you to start on this right now, you already "made my day", horst. Thank you! People waited since 2011 for the solution like this, and I got it in just one night. Isn't it a miracle? P.S. I think this module should make its way to the directory. Edited October 5, 2014 by Ivan Gretsky 1 Link to comment Share on other sites More sharing options...
horst Posted October 5, 2014 Share Posted October 5, 2014 @Ivan: I appreciate your contributions / tipps. But, - 1) the script was hacked together last night in under 30 minutes including testing. It comes from that source (a proof of concept) 2) there is a very big black hole whith this: The script iterates over imagefields and than over single images, calling getVariations() bzw. removeVariations(). That's all. This leads into that all images used by RTE-Fields on the same page could not be identified as those. So the script simply deletes them too There may be a possibilty to detect some of the embedded images in RTE-fields, those using an HTML <img tag, but there are a lot of known and unknown possibilties how images can be embedded into RTEs. Think of HannaCodes, Markdown, BBCode, other Tools/Modules that store (generic) code into RTE's to later on runtime build a proper URL or img tag from it. All those get dropped and cannot recreated automatically, like those from imagefields. Also CropImage-fields will lost there individual CropAreas and fall back to automaticlly created ones. Therefore this is a very pour solution, only offered to some people here who do know about that risc and who are able to handle that right (during development only). (hopefully) As long as there is no solution that can cover the above noted cases, I do not release it elsewhere. Finally I'm glad that it can be of help in a small use case. 3 Link to comment Share on other sites More sharing options...
tpr Posted May 23, 2015 Share Posted May 23, 2015 So please double check that you do not use Pageimages in your RTE fields before running this module. RemovePageimageVariations is a great tool but unfortunately this limitation makes it hard to use. How about adding a check to delete only variations where the field name does not have "rte" in it? // after line 109 // do not process fields having "rte" in name (eg. "images_rte") if(strpos($field->name, "rte") !== false) { continue; } I know it is hacky but allows adding fields to pages where images won't be deleted. Of course I'm open to other solutions too. Link to comment Share on other sites More sharing options...
horst Posted May 23, 2015 Share Posted May 23, 2015 Yep, you can exclude fields on a page. This is not a hacky solution, you can use it as a customized version, or you make the module configurable with at least one Textarea field where you define imagefields to exclude, one per line. This way you can drop it into diferent sites and no need to hack. Link to comment Share on other sites More sharing options...
tpr Posted May 23, 2015 Share Posted May 23, 2015 I wonder which would be a better solution: include all fields (the way it works now) and provide an exclude list setting exclude all fields by default and add an include list feature Link to comment Share on other sites More sharing options...
horst Posted May 23, 2015 Share Posted May 23, 2015 depends on how the fields are weightened, more to include or more to exclude. I prefer to write lesser. You also can make this decision configurable. ;-) Link to comment Share on other sites More sharing options...
tpr Posted May 26, 2015 Share Posted May 26, 2015 Here is the updated PageimageRemoveVariations module with the exclude list: PageimageRemoveVariations.zip I went with exclude list instead of include list to make it backward compatible. I think making exclude/include feature configurable would unnecessarily overcomplicate things. I've also added myself to the author field not to blame horst if the excludeList goes fatal 1 Link to comment Share on other sites More sharing options...
tpr Posted July 15, 2015 Share Posted July 15, 2015 Minor fix for a notice right after installing the module (undefined index). Doesn't affect anything. PageimageRemoveVariations_0.0.3.zip Link to comment Share on other sites More sharing options...
lenoir Posted September 17, 2015 Share Posted September 17, 2015 Hi there, I've been playing around with the imagesizer.php to change the quality of the images resized. However, to my surprise, if I change the setting "protected $quality = 90;" down to 80 or 70, it doesn't decrease the filesize… Am I doing something wrong? Thanks Link to comment Share on other sites More sharing options...
LostKobrakai Posted September 17, 2015 Share Posted September 17, 2015 Are you re-uploading the image or otherwise forcing a regeneration of those thumbnails? Also are you sure you're looking at thumbs and not the original image? Link to comment Share on other sites More sharing options...
lenoir Posted September 17, 2015 Share Posted September 17, 2015 Are you re-uploading the image or otherwise forcing a regeneration of those thumbnails? Also are you sure you're looking at thumbs and not the original image? I'm comparing the files in the assets folder. I've deleted the resized file in order to able PW to re-generate one. The filesize is always the same. What's a bit weird is that the filesize ends with xxx.2500x0.jpg. I don't know why it says "0" at the end. I'm using the function "->width(2500)" Should i rename the original and import it again? Link to comment Share on other sites More sharing options...
LostKobrakai Posted September 17, 2015 Share Posted September 17, 2015 It says 0 because you didn't specify a height. When using ->size(500, 300) it will be xxx.500x300.jpg. For the sizing issue I cannot help further, there are people more experienced in the topic than me. 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