Open ssitdikov opened 8 years ago
I have encountered the same problem:
use Gregwar\Image\Image;
$in = __DIR__.'/image-w800.jpg';
$out = __DIR__.'/image-w120.jpg';
$widths = [];
$image = Image::open($in);
$widths['original'] = $image->width();
$image->cropResize(120);
$widths['after-resize'] = $image->width();
$image->save($out);
$widths['after-save'] = $image->width();
print_r ($widths);
// Array ( [original] => 800 [after-resize] => 800 [after-save] => 120 )
Can confirm this issue in the latest release
This is because width()
now is just an helper and doesn't apply the queued operations
This could be fixed by applying the operations when calling width(), however this would violate the interest of the cache system in this case Can you describe me your use case so I can think a solution for this?
Ok, with a meta-data api call I want to get the dimensions of the generated images by cacheId. I tried to apply images( resource $image) , imagesy( resource $image) but failed to retrieve resource $image after creating the image with $img->png(). Any advice?
When you use cache, if there is already the file in cache absolutely no files are opened currently I think in the current release width() will work the first time because the image is generated but will still be the original width the second time I can fix that, however note that calling width() will then cost extra performances since this will open the cached file
Should be optional.
Scenario: generating and outputting responsive images with 2x resolution, so the html() method should generate something like this:
<img src="{cacheUrl}" width="{imgWidth/2}" height="{imgHeight/2}">
I did a change so that calling width()
and height()
after generating cache should work now
Example:
$img = Image::open('test.jpg')->cropResize(50, 50);
$img->width(); // Width pre-resize
$img->png();
$img->width(); // Width post-resize
thanks a lot, works perfectly!
Is this a viable solution? Why issue is still open? Some drawbacks?
Hi.
For example, for code {{ image = image(photo).cropResize(120, 120) }} {{ image.width }} will be returned original width, but must be 120 or I am not right?
Reason is the using watermark images for photo-previews, so i need return correct new width/height data, but can't.