Open grayxr opened 9 years ago
Yes, data-url
is currently always in png
format. Explicitly defining the filetype sounds like a good idea. I will add it in the next version.
Btw. you can run encode()
and cast the object to string
to get the encoded data, without accessing the property.
// encode png data-url
$encoded = (string) $img->encode('data-url');
Thanks, btw I was looking through the source code and I did see that the default data-url filetype is PNG, however, I am getting the following at the start of the default data-url data that's outputted:
'data:image/jpeg;base64'...
That's not a PNG, is it? Is it outputting as a jpeg filetype because the input image file is a JPG? If that's so, is it not feasible then to convert an image to a different filetype before encoding it as a data-url?
Thanks for the cast to string tip (don't know why it didn't cross my mind) , i was messing around with the object...
I'm trying to convert a jpg file into a png and then encode the image into a png formatted data url.
However, the first encode command seems to be skipped over when the second encode command runs.
I think explicitly defining the filetype in the 'data-url' encode command function would be awesome - ie: