Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
When processing an image through ImageAPI Optimize virtual toolkit and using as destination Amazon S3 (using s3fs module), image will get saved directly to s3fs without ever running through the optimizers. Tried with png image + optipng.
A debugging session showed that image_gd_save() will put the image in s3, then image_imageapi_optimize_save() will get a URL with 's3://' stream wrapper for $dst. Calling drupal_realpath() on that URL won't return a valid path/URL. This means ImageAPI Optimize doesn't support stream wrappers. Yet ;).
Comment | File | Size | Author |
---|---|---|---|
#10 | imageapi_optimize-2759277-10.patch | 1.55 KB | Steven Jones |
#2 | 2759277-support-remote-stream-wrappers-02.patch | 1.36 KB | jedihe |
Comments
Comment #2
jedihe CreditAttribution: jedihe as a volunteer commentedimage_gd_save() uses a workaround to properly support remote stream wrappers. I just took the code handling that and transplanted into image_imageapi_optimize_save(). Quick testing showed it working just fine (optipng, with an image style not applying any effect to just get it going through the pipeline).
Patch is attached.
Comment #3
Steven Jones CreditAttribution: Steven Jones at ComputerMinds commentedThis is pretty cool!
Needs a little clean up, because we can ignore the $success return value from our attempt at saving I think.
Comment #5
Steven Jones CreditAttribution: Steven Jones at ComputerMinds commentedComment #6
Vacilando CreditAttribution: Vacilando as a volunteer commentedThis may be needed for 7.x-2.x — or isn't it?
Comment #7
Steven Jones CreditAttribution: Steven Jones at ComputerMinds commented@Vacilando Yep, spot on. We have the same issue in 7.x-2.x.
Comment #8
Steven Jones CreditAttribution: Steven Jones at ComputerMinds commentedAnd likely 8.x-2.x too.
Comment #9
Steven Jones CreditAttribution: Steven Jones at ComputerMinds commentedFor 7.x-2.x I think we should modify
imageapi_optimize_optimize_file
so that if the file is in a remote filesystem we copy it to the temporary one, then let the processors process, and then save it back to the remote filesystem after all processing.Some of the processors could probably copy with being passed a remote file and still work fine, but it's probably an implementation detail best hidden from them.
Comment #10
Steven Jones CreditAttribution: Steven Jones at ComputerMinds commentedSomething like this.
Comment #11
Steven Jones CreditAttribution: Steven Jones at ComputerMinds commentedCould really do with testing this out.