Make WordPress Core

Opened 7 years ago

Closed 3 years ago

#40087 closed enhancement (invalid)

Add ability to filter Imagemagick processing options

Reported by: aesqe's profile aesqe Owned by:
Milestone: Priority: normal
Severity: trivial Version: 4.7.3
Component: Media Keywords: reporter-feedback
Focuses: Cc:


Hi everyone :)

TLDR: I want to be able to control Imagemagick's sampling factor value for JPEG images.

I haven't been able to find any info on whether it's possible to change this value in Imagemagick's defaults, and there don't seem to be any usable filters or actions in WP_Image_Editor_Imagick class.

To be able to set the sampling factor, one needs access to the Imagemagick instance, which is a protected var in the editor class, I guess for a reason.


a) a new public WP_Image_Editor_Imagick method which would be able to call Imagemagick instance methods, made available via an add_action call
b) add something like the following code to the set_quality method:

if( defined("IMAGICK_SAMPLING_FACTOR") ) {
    $this->image->setImageProperty('jpeg:sampling-factor', IMAGICK_SAMPLING_FACTOR);

Any ideas?


Change History (5)

#1 @aesqe
7 years ago

  • Keywords dev-feedback added
  • Severity changed from normal to trivial

This ticket was mentioned in Slack in #core-media by mike. View the logs.

5 years ago

#3 @kirasong
5 years ago

  • Keywords reporter-feedback added; dev-feedback removed
  • Type changed from feature request to enhancement

Thanks so much for the report!

At the moment, the intended way to make this change is by extending the WP_Image_Editor_Imagick class, and adding (replacing if you want) the new class to the list of editors with the wp_image_editors filter.

It's built this way to abstract away the internals of each image editor, because a filter specifically for Imagick wouldn't apply to GD, for example.

Will that work for your use-case?

This ticket was mentioned in Slack in #core-media by antpb. View the logs.

3 years ago

#5 @antpb
3 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

Hello! In a recent Media bug scrub this issue was discussed and it was determined that while not ideal to replace the entire class, it is still currently possible to replace the class and make your adjustments for your sites's specific case.

We think maybe more granular filters in the future make sense for the class to eliminate the possibility of multiple plugins overwriting each other's tweaks but that is an issue we should tackle once more experience this desire.

Will be closing this as invalid only because it's currently possible to extend the class. If you feel the need to open the ticket again, please feel free to leave a comment below. Thanks!

Note: See TracTickets for help on using tickets.