Jump to content

Where to set image resizing quality and how to re-resize images


Adam Kiss
 Share

Recommended Posts

Thank you anyways.

I've tried uploading new images with new names into a new page on a new day with a quality of 10 and still don't see any differences… Seems like this isn't working properly or that i'm doing something wrong.

Hope someone else can help?

Link to comment
Share on other sites

Filetype is JPEG you said?

If you change things for testing purposes, you can add a param "forceNew" => true to an options array to always override previous versions. And if you want check filesize compared to quality settings you can use the suffix setting for a complete check loop like that:

$img = $page->images->first(); // grab you an image (change code to match your setup)
$newWidth = ($img->width == 2500) ? 2499 : 2500;  // set a width value different than the original image size! (is needed for the test only)

$qualities = array(100, 90, 80, 70, 60, 50, 40, 30, 20, 10);
foreach($qualities as $q) {
    $options = array('forceNew'=>true, 'quality'=>$q, 'upscaling'=>true, 'sharpening'=>'soft', 'suffix'=>"quality{$q}");
    $variation = $img->width($newWidth, $options);
    echo "<p>variation: {$variation->name} :: " . filesize($variation->filename) . "</p>";
}

Code is written in browser, if it doesn't work as expected, please check for typos or come back here and tell me.

And if it works, please drop a note about the result. :)

  • Like 5
Link to comment
Share on other sites

  • 7 months later...
  • 4 months later...
On 5/10/2014 at 2:28 PM, horst said:

I have made a module for you (all). :ph34r:

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!

Hi @horst - this module is great and I use it regularly. Only problem is that it causes a deprecated constructor notice in PHP7 (class "filo" has a method "filo" rather than "__construct"). Would you mind updating it? And maybe submit it to the modules directory too?

I could update it for my own use but it would be cool to have an "official" version. :)

  • Like 1
Link to comment
Share on other sites

@Robin S, you should ask @tpr, - he has made the last / enhanced version, if he updates it.

EDIT:

and if tpr cannot further maintain it, it would be fine if you can do!? (I already have enough modules in the directory, that all need to be maintained)

Edited by horst
Link to comment
Share on other sites

On 16/07/2015 at 0:04 AM, tpr said:

Minor fix for a notice right after installing the module (undefined index). Doesn't affect anything.

PageimageRemoveVariations_0.0.3.zip

Hi @tpr - would you mind updating the module to fix the deprecated constructor? Thanks. :)

16 hours ago, Robin S said:

Hi @horst - this module is great and I use it regularly. Only problem is that it causes a deprecated constructor notice in PHP7 (class "filo" has a method "filo" rather than "__construct"). Would you mind updating it? And maybe submit it to the modules directory too?

 

Link to comment
Share on other sites

  • 3 weeks later...

The update throws an error here on PW 3.0.39 (a problem with namespace?):

79:     require_once(\ProcessWire\wire('files')->compile(dirname(\ProcessWire\wire("config")->paths->root . 'site/modules/PageimageRemoveVariations/PageimageRemoveVariations.module') . '/PageimageRemoveVariationsConfig.php',array('includes'=>true,'namespace'=>true,'modules'=>false,'skipIfNamespace'=>false)));
80:            $c = new \ProcessWire\PageimageRemoveVariationsConfig();

 

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...