Jump to content

Recommended Posts

Is there a way to make JPGs progressive by default via the API?

I've added the following to my site/config.php file but user-uploaded images are often displayed as non progressive.

$config->imageSizerOptions = array(
	'upscaling' => true, // upscale if necessary to reach target size?
	'cropping' => true, // crop if necessary to reach target size?
	'autoRotation' => true, // automatically correct orientation?
	'interlace' => true, // use interlaced JPEGs by default? (recommended)
	'sharpening' => 'soft', // sharpening: none | soft | medium | strong
	'quality' => 95, // quality: 1-100 where higher is better but bigger
	'hidpiQuality' => 60, // Same as above quality setting, but specific to hidpi images
	'defaultGamma' => 0.5, // defaultGamma: 0.5 to 4.0 or -1 to disable gamma correction (default=2.0)
	);

Thanks

Share this post


Link to post
Share on other sites

For what I have experienced, the interlace parameter should be enough. Also, be aware that any previously created image won't behave as progressive. 

Share this post


Link to post
Share on other sites

I guess I'm totally wrong with that but somehow my mind tells me that you will need ImageMagick/IMagick support for this.

 

  • Like 1

Share this post


Link to post
Share on other sites
15 minutes ago, wbmnfktr said:

I guess I'm totally wrong with that but somehow my mind tells me that you will need ImageMagick/IMagick support for this.

 

Apparently not! This is the file for the GD engine, found it in the github issues where where this feature was being discussed and @horst published changes for both GD and imagemagick engines.

https://github.com/horst-n/processwire/blob/f072a52ccec7ffadd6831b5002ebd0b569274216/wire/core/ImageSizerEngineGD.php#L286

But maybe GD needs something else (some config?) to support it??

Share this post


Link to post
Share on other sites

Ok... my mind seems more reliable than I thought. 😄

I wish I could find that thread or post where it was discussed back than. 

  • Like 1

Share this post


Link to post
Share on other sites
1 hour ago, wbmnfktr said:

I wish I could find that thread or post where it was discussed back than. 

Truth is I would have also assumed ImageMagick as a requirement!

  • Like 1

Share this post


Link to post
Share on other sites

Probably totally stupid question, but do the user-uploaded images go through PW-side image processing at all?

  • Like 1

Share this post


Link to post
Share on other sites
22 minutes ago, Autofahrn said:

Probably totally stupid question, but do the user-uploaded images go through PW-side image processing at all?

I have some width and height restrictions on my images field so the image gets uploaded and resized. In this case I'd assume anything specified in the 

Quote

$config->imageSizerOptions = array(

gets applied. But i'm only guessing.

  • Like 1

Share this post


Link to post
Share on other sites
7 hours ago, Autofahrn said:

Probably totally stupid question, but do the user-uploaded images go through PW-side image processing at all?

You can learn about it in this post: 

 

Also note that since ProcessWire 3.0.63 client-side resize gives us another option in the mix https://processwire.com/blog/posts/processwire-3.0.63-adds-client-side-image-resizing/

So it all depends on how you set it up and implement it. It is possible to serve unaltered images if you make sure PW does not touch it in the first place. However, it is only recommended for tech tech-savvy users or for special use cases.

Edited by szabesz
typo

Share this post


Link to post
Share on other sites
4 minutes ago, szabesz said:

You can learn about it in this post:

yup, it says

Quote

the original uploaded files never get altered

So if an image is simply uploaded and downloaded without manipulation (i.e. sizing), the original, unaltered version should be retrieved. At least that's the case in all my setups.

  • Like 1

Share this post


Link to post
Share on other sites
5 minutes ago, Autofahrn said:

yup, it says

Quote

the original uploaded files never get altered

However, there are exceptions as noted 🙂 the max size image imagefiled constrain and/or client-side image resizing might result in having a different file stored instead of the original supplied.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By jom
      Hi everyone
      It seems that I don't fully understand the wireTempPath() function and I need some help.
      I use wireTempPath() to create a new location in assets/cache/WireTempDir and than copy a pdf from the assets/files/page folder to the new folder. I want the file to be accessible only for a limited time, that's why I use wireTempPath.
      The file seems to be copied to the right location, but gets deleted right afterwards, according to 
      As mentioned in the topic above, 
      $wireTempDir->setRemove(false); prevents the file to be deleted. But I like the file to be automatically deleted after a few days. So, how can I do that?
      My code so far (everything works, but the automatic removal of the tempDir folder):
      //generate and show download link $folder = time(); // timestamp as temporary folder $maxAge = (int) $settings->options_downloadlink_valid_hours * 3600; //tempDir wants maxAge as seconds $options = array( 'maxAge' => $maxAge ); $wireTempDir = wireTempDir($folder, $options); $wireTempDir->setRemove(false); $src_file = $page->ebook_download->filename; // Create a new directory in ProcessWire's cache dir if(wire('files')->mkdir($wireTempDir, $recursive = true)) { if(wire('files')->copy($src_file, $wireTempDir)){ //get subdirs from tempDir: $pos = strpos($wireTempDir, "WireTempDir"); $subdir = substr($wireTempDir, $pos, 100); $out .= "<p><a href='" . wire('pages')->get('template=passthrough')->httpUrl . "?file=" . $subdir . $page->ebook_download->basename . "' target='_blank'>$page->title</a></p>"; } } I appreciate any ideas - thanks!
      Oliver
    • By Hardoman
      Hello community,
      we have a website running version 3.0.118. The owner would like to have a watermark merged to the images, that are being uploaded in the CKEditor as a requirement.
      Image upload besides the CKEditor within galleries and single images works as a charm already. We also use croppable image 3 there. (PIM2)
      To realize this requirement, I thought of using a hook in the admin area. So, I read a lot in our forums and tested this by adding a hook into the ready.php file.
      $this->addHookAfter('InputfieldFile::fileAdded',function(HookEvent$event){ wire('log')->save('test','Image upload works'); ... The log entry is being created correctly. But when I try to use the pim/watermark-function like in a template, he cannot find the watermark-image anymore. Furthermore, when I try to get the page-id, it does not seem to be accessible, because the application does not seem to know how to reference it, or I dont know the right way to do so…
      So my questions are:
       
      Is this the right attempt at all or will there be another, better workaround? It seems, I cannot access the page object (of the content page) within this scope or file but I would need it to save the processed image inside the right files/id folder Would it be better to place the hook into the admin-template? (or admin.php)
        Thanks for any hints in advance. 🙂
    • By toni
      Hi,
      I'm facing a strang problem. In my template I'm setting different sizes for srcset:
      $view->set('images', $page->picture); <img srcset="{$img->size(780,0)->url} 780w, {$img->size(1024,0)->url} 1024w, {$img->size(1440,0)->url} 1440w" src="{$img->url}" class="col__image"> All fine. However, the moment I reorder images in backend the different generated image sizes are broken.
      Does somebody has an idea what could cause it? 
      Version: ProcessWire 3.0.123 
       
      Thanks!
      Toni
    • By VeiJari
      Hello forum, this is my first security related post, so I'm a bit of a newbie.
      I understand that when I have direct front-input from user I should sanitize the input, but how about when I use a secret key for showing a API for a third-party supplier? Should I sanitize the input->get() key?
      I've tested this issue and I tried ?key=<?php echo $page->field; ?> And without adding any sanitization it comes back: /?key=<?php%20echo%20$page->field;%20?>
      So can I rely on this, or should I still use $sanitizer just in case?
       
      Thanks for the help!
    • By nabo
      Hello
      I'm working on a project that use PW as backend CMS. PW serves formatted data of each page but the engine simply generates json from pagearray.
      I would like to set one or more variations on images, so I think it would be useful if there were a field to set possible variations... even with overrides!
×
×
  • Create New...