WordPress.org

Make WordPress Core

Opened 4 weeks ago

Last modified 4 weeks ago

#50630 new defect (bug)

imagick image editor does not support streams

Reported by: p00ya Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: trunk
Component: Media Keywords:
Focuses: Cc:

Description

The imagick image editor (in particular the load and save methods) do not work with streams.

The use case for having the image editor work with streams is when using plugins like https://wordpress.org/plugins/gcs/ that register a custom stream handler (in that case for "gs://" URLs) and add a filter to upload_dir so that uploads result in RPCs to external services.

There are a few reasons the original code didn't work:

  • realpath doesn't work with streams
  • Imagick::readImage and Imagick::writeImage expect filenames, not URLs

I have a working patch which I'll upload to this ticket.

Attachments (1)

50630.diff (4.0 KB) - added by p00ya 4 weeks ago.
Patch for #50630

Download all attachments as: .zip

Change History (2)

@p00ya
4 weeks ago

Patch for #50630

#1 @p00ya
4 weeks ago

Some notes on the patch:

The patch uses Imagick::getImageBlob and Imagick::readImageBlob. I did also investigate using readImageFile and writeImageFile, but these appear to misbehave with some stream handlers (probably a bug in the PHP extension?).

Note: See TracTickets for help on using tickets.