1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Lack of Interest Better compression of jpg preview images

Discussion in 'Media Gallery Closed Suggestions' started by otto, Feb 20, 2015.

  1. otto

    otto Well-Known Member

    Hello,

    today i look a litle bit on my site speed - and i see, a preview image (every!) in the Media Gallery will have a big file size, a to big file size:

    A preview image in 150x150px will have 20 to over 30 kbyte in file size - that is realy to big.

    So my suggestion for the media gallery is - pleas give us a option to reduce the saved quality of every preview pics to increase the file sizes for a faster page load. :)

    Regards
     
    RoldanLT, rafass and 51463 like this.
  2. jauburn

    jauburn Well-Known Member

    What do you consider a reasonable file size? And why do you think the Media add-on keeps such large files?
     
  3. otto

    otto Well-Known Member

    XMG saves jpg files with 100% quality - so, especialy for the thumbs, it would be better to save jpgs with 90-95% jpg quality to save disk space and traffic for a faster page load and smaller backups.

    I believe in a XMG version bevor, we have a option to set this quality setting - but in 1.0.3 I dont can find anything like this.

    I edit the core files to solve this for me:

    for XenGallery 1.0.3
    change JPG compression:
    - /httpdocs/forum/library/XenGallery/Helper/Image.php
    160
    PHP:
    public function resize($max_width$max_height$method 'fit'$cropAreaLeftRight 'c'$cropAreaBottomTop 'c'$jpgQuality 90)
    348
    PHP:
    public function cropExact($x$y$width$height$jpgQuality 90)
    With this litle change XMG now saves me smaller jpg files as bevor so I think, why not a option in ACP for it? ;)
     
    eva2000 and Nuno like this.
  4. Nuno

    Nuno Active Member

    Hello,

    I was trying to change the resize funciotn to $jpgQuality = 75 but the results are the same as with 90.
    Shouldn't the image be smaller?

    Thanks
     
  5. FredC

    FredC Well-Known Member

    I dont own XFMG but i assume you would need to Rebuild something similer to Rebuild Attachment Thumbnails.. (ACP, Tools, Rebuild Caches, ???)
     
  6. Nuno

    Nuno Active Member

    Hi,

    Just tested uploading the same image twice .. one with 90 and the other with 75 and both have the same size.
    They should have different sizes.

    Thanks
     
  7. otto

    otto Well-Known Member

    Hmmm... here it works like it should. (Xenforo 1.4.8 and XFMG 1.0.6)

    An other way can be, to use jpgtran on the linux console and a shell script (cron) to shrink every night the new jpegs.
    But as I say - in my case it works just fine...
     
    Nuno likes this.
  8. DroidOne

    DroidOne Well-Known Member

    Nuno likes this.
  9. Nuno

    Nuno Active Member

    I 'mogrify'ed all images this weekend when I move from IPB to XF.
    I was trying to get the most from the optimization from that function, but either with quality 50, 75 or 90 I get always the same size from the same image (133kb)

    I even reset APC cache to force script update.

    I tested with mogrify and I get with quality 50 81kb and with 75 121kb.

    Why changing this value images are always the same size?

    @Chris D maybe my questions should be moved to support. I didn't notice this topic was in the suggestions categroy
     
  10. Chris D

    Chris D XenForo Developer Staff Member

    It's not really feasible to move suggestion threads so creating a new thread in the Support forum would be more appropriate. However, there's probably not a lot we can advise on this.

    I don't have a particular explanation as to why the quality parameter isn't appearing to work but I can certainly confirm the same as otto - it is working as intended for me.

    Just a bit of background info, on that; the quality parameter will only apply to JPG source images.

    We don't pass it in to PNG, for example, because the default compression level of 6 (IIRC) is used and PNG compression is lossless so it should always produce a reasonable result quite speedily.

    The quality parameter is fed directly into PHP's imagejpeg function. If you set that number to 50, the JPG quality will be 50. There's no code in between that would change that.

    So ultimtely, this is suggesting that you're either using a PNG, there's some sort of caching involved, or you're hitting some weird bug in PHP somewhere that is for some reason ignoring the quality setting.
     
    otto and Nuno like this.
  11. otto

    otto Well-Known Member

    Hello Chris,

    if you have Paint.NET in its latest Version and if you use the plugin "JPGoptim" and "PNGoptim" you can see what a realy good image compression can do. This both plugins shrink jpg and png image files much better than the default settings it can.

    On server side, we have tools like "jpegtran" or "PNGquant" and "pngcrush" as realy good solutions - but its not used by xenforo or its add-ons.
    Disk space costs not realy many money, but google looks since a longer time on pageload/pagespeed. And thats good for all. ;)
     
    Nuno likes this.
  12. otto

    otto Well-Known Member

    Last edited: Jun 25, 2015
    Nuno likes this.

Share This Page