I’m using the Imageset for responsive fast loading images, however, I’m having a problem with images that don’t have an sRGB colorspace - the colours come out muted and not a vibrant as they should be. I don’t want the client to have to export images manually with an sRGB colorspace so I would like (if possible) to automate this conversion. To do this I have created a custom driver by using ImageMagick as a base.
/plugins/profile-driver/profile-driver.php
<?php
thumb::$drivers['pd'] = function($thumb) {
$command = array();
$command[] = isset($thumb->options['bin']) ? $thumb->options['bin'] : 'convert';
$command[] = '"' . $thumb->source->root() . '"';
$command[] = '-strip';
// Added the colorspace flag and profile
$command[] = '-colorspace sRGB';
$command[] = '-profile sRGB.icm';
if($thumb->options['interlace']) {
$command[] = '-interlace line';
}
if($thumb->source->extension() === 'gif') {
$command[] = '-coalesce';
}
if($thumb->options['grayscale']) {
$command[] = '-colorspace gray';
}
if($thumb->options['autoOrient']) {
$command[] = '-auto-orient';
}
$command[] = '-resize';
if($thumb->options['crop']) {
if(empty($thumb->options['height'])) {
$thumb->options['height'] = $thumb->options['width'];
}
$command[] = $thumb->options['width'] . 'x' . $thumb->options['height'] . '^';
$command[] = '-gravity Center -crop ' . $thumb->options['width'] . 'x' . $thumb->options['height'] . '+0+0';
} else {
$dimensions = clone $thumb->source->dimensions();
$dimensions->fitWidthAndHeight($thumb->options['width'], $thumb->options['height'], $thumb->options['upscale']);
$command[] = $dimensions->width() . 'x' . $dimensions->height() . '!';
}
$command[] = '-quality ' . $thumb->options['quality'];
if($thumb->options['blur']) {
$command[] = '-blur 0x' . $thumb->options['blurpx'];
}
$command[] = '-limit thread 1';
$command[] = '"' . $thumb->destination->root . '"';
exec(implode(' ', $command));
};
and enabled this in config.php
c::set('thumbs.driver', 'pd');
This does not seem to be having any effect. Does anyone have any ideas about what I may be doing wrong or how I could achieve this?