Hi again.
I'm trying to set a image with and height before make a crop. So I found apply() method in your image package.
But, how can I do using manipulationsfield?
Or how can I set an array manipulations like:
$manipulations = [
'resized' => [
['width' => $imageWidth, 'height' => $imageHeight],
['manualCrop' => $imageWidth.', '.$imageHeight.', '.abs($value['imageLeft']).', '.abs($value['imageTop'])],
],
];
Thanks!
Hi @Krato
I don't think it's possible (yet) to use the apply method on media specific conversions since it's not really a manipulation in the first place.
All the apply method does is start a new manipulationSequence every time it's called. When you're using media specific conversions the entire array you provided will be used as a manipulationSequence without checking for apply.
I do see the need for different manipulationSequences when using media specific conversions and I think the example you provided would be a nice way to implement that.
Once that's in place another option might be to add a toArray method on the Conversion class, this way you could create Conversions just like in your HasMedia models and add those to the specific media:
$resizedConversion = Conversion::create('resized')
->width(123)
->apply()
->manualCrop(20, 20, 10, 10);
$media->manipulations = [
'resized' => $resizedConversion->toArray()
];
I'd accept a PR that adds support for multiple media specific manipulationsSequences.
For the easy building of a manipulations array I'd accept PR on spatie/image that adds a static create method and an toArray method on Manipulations.
So when can do this:
$resizedConversion = Manipulations::create()
->width(123)
->apply()
->manualCrop(20, 20, 10, 10);
$media->manipulations = [
'resized' => $resizedConversion->toArray()
];
Hope I understand.
Now I get it working just modifying manipulations.php fle.
Here is the pull: https://github.com/spatie/image/pull/16
Pull Merged!
@freekmurze
`$resizedConversion = Manipulations::create()
->width(123)
->apply()
->manualCrop(20, 20, 10, 10);
$media->manipulations = [
'*' => $resizedConversion->toArray()
];
$media->save();`
I want to crop image and my code is as above.
it is regenerating conversions but cropping is not working.
Most helpful comment
I'd accept a PR that adds support for multiple media specific manipulationsSequences.
For the easy building of a manipulations array I'd accept PR on
spatie/imagethat adds a staticcreatemethod and antoArraymethod onManipulations.So when can do this: