Closed garygreen closed 7 years ago
I think the behaviour is correct here Why don't you write:
<?php
$image->negate();
$new = clone $image;
$image->resize(100, 100);
$new->resize(200, 200);
@Gregwar this isn't a problem limited to clone. If you do multiple calls to ->resize
it shouldn't attempt to resize multiple times - it should overwrite the existing resize call imo.
This is a problem when you want to overwrite the resize method but can't stop the existing resize one being called (i.e. it's done from non userland code).
I do agree cloning all the operations is expected, which it will still do, but it just allows easier overriding of operations on the cloned object.
The other option would be some kind of clearOperations
function something like:
$image->negate();
$image->resize(200, 200); // This cannot be changed.
$new = $image->clone();
$new->clearOperations(['resize', 'negate']);
$new->resize(200, 200);
Hmm then again I supose it doesn't make sense for things like ->line
and other stuff, you may want to do operations multiple times. Maybe need to rethink how doing this
If you do
$image->resize(100, 100)
subsequently$image->resize(200, 200);
it will apply both resize operations to the array.My use case is I basically want to clone an existing image instance, and then apply a different resize (keeping all the existing operations and settings). If I do:
The
$new
instance has both the resize operations for 100x100 and 200x200 when it should only have one, as the lastresize()
operation should have overridden it.Also it duplicates the hash, so it doesn't properly detect to save a new image.