CreunaFI / color-space-fixer

WordPress plugin to convert Adobe RGB / CMYK images to sRGB automatically. Requires ImageMagick built with lcms delegate.
https://creunafi.github.io/color-space-fixer
16 stars 1 forks source link

Fatal error #1

Closed marcorroma closed 4 years ago

marcorroma commented 4 years ago

Hi, when I activate your plugin I have this error: _The plugin cannot be activated because it generates a fatal error. Fatal error: Uncaught Error: Call to a member function getVcsApi() on null in /var/www/html/wp-content/plugins/color-space-fixer-master/functions.php:21 Stack trace: #0 /var/www/html/wp-admin/includes/plugin.php(2223): include() #1 /var/www/html/wp-admin/plugins.php(175): plugin_sandboxscrape() #2 {main} thrown in /var/www/html/wp-content/plugins/color-space-fixer-master/functions.php on line 19 Thanks

PS. Even removing from line 19, to line 21. I can't activate the plugin. Fatal error. I use Ubuntu 19.10 + apache + php7.4fpm

joppuyo commented 4 years ago

Hey,

How did you download the plugin?

Did you download the plugin zip using GitHub releases or are you using Composer?

marcorroma commented 4 years ago

I downloaded the zip file from Github. Then I uploaded the file to Wordpress via backend (no ftp). I also tried uploading via ftp. Same activation error.

marcorroma commented 4 years ago

I removed this code from functions.php and it now works:

$update_checker = Puc_v4_Factory::buildUpdateChecker(
    'https://github.com/CreunaFI/color-space-fixer',
    __FILE__,
    'color-space-fixer'
);

$update_checker->getVcsApi()->enableReleaseAssets();

A request, can not convert the dpi of the uploaded images? Example. If I upload an image on Wordpress with 180dpi it should be converted to 96dpi. Currently it does not happen. What do you think about it?

Edit. Would it be a positive idea to also remove the exif data?

joppuyo commented 4 years ago

Hey, did you download the zip from GitHub releases? https://github.com/CreunaFI/color-space-fixer/releases

If you download the source code straight from the GitHub page, Composer dependencies will be missing and you will be unable to use auto-update.

A request, can not convert the dpi of the uploaded images? Example. If I upload an image on Wordpress with 180dpi it should be converted to 96dpi. Currently it does not happen. What do you think about it?

I don't completely understand this. Do you think the DPI be converted or not? Can you describe what the current behavior is and what would be the ideal behavior?

In any case, the DPI is just metadata and it doesn't affect the resolution of the image or how it's displayed on the site. DPI is only relevant if you print the image.

Edit. Would it be a positive idea to also remove the exif data?

I think it would make more sense to implement this in another plugin since EXIF data not really relevant when it comes to color spaces and I want this plugin to be focused and not to become a catch-all image plugin.

joppuyo commented 4 years ago

Also, EXIF data should be removed after image has been uploaded since WordPress will actually store some of the metadata in the database and it can't do it if it's stripped too early.

marcorroma commented 4 years ago

Hi, I downloaded the plugin from GitHub releases, it is now functional.

dPI: CMYK files are usually used for printing and have a high resolution in dpi. If I upload a CMYK image it has 180 or 300dpi it is converted to sRGB but not to 96dpi. You would have a better image optimization for the web, with better use of the file size.

EXIF: Thanks a lot. I tried to look for some plugins to remove exif but they don't exist. Or rather, they exist but they don't work.

joppuyo commented 4 years ago

Hey, great thing you got it to work!

CMYK files are usually used for printing and have a high resolution in dpi. If I upload a CMYK image it has 180 or 300dpi it is converted to sRGB but not to 96dpi. You would have a better image optimization for the web, with better use of the file size.

The DPI value of the image is a piece of metadata embedded in the file and it doesn't affect the size or the resolution in any way when displayed on a screen. Changing the DPI value in the metadata only affects the physical size of the image if you print it.

Here's more reading on the subject: https://daraskolnick.com/image-dpi-web/

But I think one way DPI can have relation to the file size.

Let's say you scan an A4 document at 300 DPI, it will be 2480 x 3508 px. If you scan the same document on 96 DPI, it will be 794 x 1123 px. So, in this case, the pixel dimensions are larger with bigger DPI.

So basically the DPI value only matters when you scan or export an image out of Photoshop or InDesign because it affects the pixel size.

So basically if this plugin would "change the DPI" in reality it would have to read the DPI value, scale down the image to pixel size to 96 DPI equivalent and update the image metadata to say it's a 96 DPI image.

If you are worried that your images are too large, you could use a plugin like Imsanity to set maximum pixel size for your image. WordPress 5.3 already does this by default if your image is larger than 2560px.

I have to think about if such a feature could be implemented in this plugin. In any case it should be opt-in since many people want high-quality images.

Thanks a lot. I tried to look for some plugins to remove exif but they don't exist. Or rather, they exist but they don't work.

It shouldn't be too hard to write this kind of plugin, I'll have to look into this when I have free time.

I'm just a bit hesitant to add new functionalities in this plugin because I want to keep it focused. I originally wrote it so solve one problem that I was having and nobody else had solved before. So I don't want to turn it into a kitchen sink sort of thing that does a whole bunch of things related to images. There are too many WordPress plugins like Jetpack which is a collection of a bunch of unrelated functionality.

marcorroma commented 4 years ago

Thanks for sharing this plugin and your support with me. DPI problem: I'll give you an example, I have a 300dpi CMYK file. This file weighs 835kb. I upload the file in Wordpress, it is converted to RGB. Now I have an image (scaled to 980x589px) in RGB at 300dpi. This file weighs 125kb. If this file were converted to 96dpi it would weigh 89.9kb. It always has 980x589px. (I used online conversion tool: tinypng.com)

I believe that Wordpress does not "understand" the image Dpi, but treat 300dpi in the same way as 96dpi. I'm sure this would make the images weigh less kilobytes. What do you think about it?

PS. Imsanity is already active on my site. But 500x500px 300dpi are equal to 500x500px 96dpi for Wordpress. But the size is different.

joppuyo commented 4 years ago

Could you share these 2 files with me? I could check what is causing the disparency with the file sizes.

Thanks!

marcorroma commented 4 years ago

Certainly. Thanks for your support. Here is a zip with the 3 files (CMYK, RGB 300dpi, RGB 96dpi) https://gofile.io/?c=sgfwt9

joppuyo commented 4 years ago

Thanks!

If I use ImageMagick's identify tool, I can see that the 300dpi image has been compressed with the quality of 82 and the 96 dpi image has been compressed with the quality of 75 which is why the latter is smaller: https://www.diffchecker.com/Y575rRVj

If you change the WordPress image quality to 75 using code like:

add_filter('jpeg_quality', function($quality) {
  return 75;
});

Both files should be the same size after that. Because the resolution is the same, the DPI is just metadata which takes up practically no space compared to changing the compression quality.

marcorroma commented 4 years ago

Thank you. Now I understand, it was a quality set problem. Thanks for your time, and congratulations on your plugin.

simplenotezy commented 4 years ago

You need to run composer install inside the plugin directory to get rid of the error.

Main problem is: /vendors/ folder is in gitignore, and it shouldn't be.

marcorroma commented 4 years ago

You need to run composer install inside the plugin directory to get rid of the error.

Main problem is: /vendors/ folder is in gitignore, and it shouldn't be.

Thanks