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

Resizing Image Proxy images results in corrupted image files...

Discussion in 'XenForo Development Discussions' started by DeltaHF, Mar 9, 2015.

  1. DeltaHF

    DeltaHF Well-Known Member

    I'm hacking the Image Proxy to downscale large images, server-side, before caching them.

    I have added the following code to ../Library/XenForo/Model/ImageProxy.php, starting at line 315 (just inside the if (!requestFailed){ ... } block):

    PHP:
    $imageInfo = @getimagesize($streamFile);
    $imageInfo['width'] = $imageInfo[0];
    $imageInfo['height'] = $imageInfo[1];
    $imageInfo['type'] = $imageInfo[2];
               
    $maxWidth 800;
    $maxHeight 3000;
               
    if (
    $imageInfo['width'] > $maxWidth)
    {
       if (
    XenForo_Image_Abstract::canResize($imageInfo['width'], $imageInfo['height']))
       {
            
    $tempImage XenForo_Image_Abstract::createFromFile($streamFile$imageInfo['type']);
            
    $tempImage->thumbnail($maxWidth $maxWidth $maxHeight$maxHeight);
            
    $success $tempImage->output($imageInfo['type'], $streamFile95);
                     
            if (
    $success)
            {
                
    $fileSize filesize($streamFile);
            }
        }
    }
    This works... but only in Chrome. Firefox just downloads part of the image, Safari reports a "network connection was lost" error in the console (and doesn't show the image unless you load it directly), and IE shows corrupt pixels (on some images, they're green):

    corrupt.jpg

    You can view this file for yourself from my Image Proxy right here, and you can view it in context (with lots of other corrupted images) in this thread.

    I have researched this as much as I can, but now I'm stuck. Any ideas on how I could fix this?
     
  2. Amin Sabet

    Amin Sabet Well-Known Member

    Did you ever figure this one out? I would love to do something like this.
     
  3. DeltaHF

    DeltaHF Well-Known Member

    Sadly, no.

    It's still a feature I would really like to have so users can't overwhelm threads with lots of large images. Let me know if you have any luck.
     
    Amin Sabet likes this.
  4. Nuno

    Nuno Active Member

    Hi,

    Any news on this? I would like to implement this feature.
     
  5. DeltaHF

    DeltaHF Well-Known Member

    @Amin Sabet and I commissioned this as an add-on by @MtoR. I don't know if he's planning on releasing it to the public.
     
  6. melbo

    melbo Well-Known Member

    Would be interested
     
  7. MtoR

    MtoR Well-Known Member

    I am not planning to release it to public as it's very specific but you guys can contact me per PM to buy it.

    Clément
     
    Amin Sabet and DeltaHF like this.

Share This Page