Skip to main content

Changing the image workflow

In one of my previous blog posts I talked about changing the image editor UI. But this is just a small thing in the whole workflow of dealing with images. Some of the pain points are within how we deal with creating image sizes and how we can edit those and I will going to spent a lot of my time to address those in 3.9 and 4.0.

So in the previous blog post I discussed the need of a better UI and how we can use that. But there needs to be more done to make the whole workflow better. Like having a WP_Image class. Our end user need a better workflow but also as a developer we need to have new hooks and better API’s.

Crop position

In ticket 19393 I expressed my feelings to now have the ability to select the default value. The reason is that I think we can do something better and that is automatic detection of the best center point and crop around that. But after thinking a bit more on this subject due this post I think that this will be very experimental in the beginning. So I think we can have something like:

<?php add_image_size( $name, $width, $height, $crop, $args ); ?>

Here $crop will be a boolean, string or an array. The default value still will be false. The string can only be ‘auto’ what allows someone to enable auto detection. The array will be the crop position so to left/center/right and top/center/bottom.

The args will be an array to pass extra options to WP_Image_Editor. An idea is to use this to pass a zoom value. This could be ideal for smaller images. Another thing it could be use for is to pass in a filter it needs to run like grayscale. It will give a lot of options for using image sizes. The patch on the trac ticket only needs a refresh to change the documentation in all our WP_Image_Editor’s and we need a new ticket for the args parameter.

Manually setting the position

More then two months ago I had a great discussion with Jean Galea and Bjørn Johansen about setting the thumbnail crop position instead of making a crop. There are a few plugins out there and they do work really nicely. I’m unsure if this is something we should provide but I guess in the end you will have almost always have the same result. Because an image size is bound to it’s height and width. Only when the value is 0 or really high it may not be able to. But it would be great for what I discussed before to specify a zoom for smaller images. The center point is getting more difficult to use then.

Automatic detection

This was another point we had a discussion about. As mentioned before this is really experimental but it can make WordPress a way better platform for dealing with images. There is a project called php-facedetection. It was a project I saw when I was building WP_Image_Editor. And I was planning to build a plugin for that but the guys from interconnect/it were a bit faster then me. The called their plugin My eyes are up here. This plugin will detect images on a picture and use that for their crop. They now use Javascript detection and some of the code is rough but it does show potential.

Obviously the code can be better and the detection should not be faces only. I personally always loved OpenCV and I don’t know if we can use that or not. It all depends on how fast we can do the automatic detection and how good the results are. Depending on the result we can decide if it’s something we can provide. It depends on storing the center point and the ability to enable this per image size.

Image sizes and image editing

Something that I would love to change is applying changes to custom image sizes. On trac it has already quite a few comments. The code to apply all the changes still need to get but I would love to make some UI changes what means reducing the functionality a bit. My idea is to always apply the changes to all images. This allows us to store the information of a crop what then can be used to regenerate images without breakage. This will also reduce one issue for generating images on the fly. I think not a lot of our users use this and when they do use it they want more. So I think this can be dealt in a plugin but it will need a few hooks to be able to do this.

This will mean that ticket #11895 needs to be closed as wontfix since this need to be done in a plugin.

Others

Obviously there are more areas we need to fix but for core this are the pain points for now. Creating the images and be able to change them. Other issues that need to be addressed are managing all our media files. I already build one plugin for this and hopefully I can release it next month. Hopefully by the end of this year most of this issues are solved. In core or with plugins that can hook into core.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.