liias / imagerotate

Image rotate plugin for CKEditor
1 stars 2 forks source link

ckeditor image rotate fails #1

Open aristos32 opened 7 years ago

aristos32 commented 7 years ago

I use symfony with ckeditor for my forms. I installed the 'rotate image' plugin.

When I rotate an image, and then I try to save a form, and it works fine on my localhost but fails on the server.

On the server it tries to upload the image as content of the form, and it gives me error:

Warning: Error while sending QUERY packet. PID=31523 in /vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php on line 1124

This seems like a configuration issue. Any hint will be much help.

liias commented 7 years ago

OK, so looks like there are issues with data uri images in general. E.g do you get the same error when putting to source something like this?

<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" />

liias commented 7 years ago

Googleing about that query packet error I found this http://stackoverflow.com/questions/30753674/error-while-sending-query-packet

This hints that the data uri image just makes the source text too long and doesn't fit in max_allowed_packet size defined in mysql configuration. (Do you use mysql?)

aristos32 commented 7 years ago

Hi Ilias. Yes I noticed that in localhost, after first rotate, the img uri gets the form you described:

<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" />

However in server, since it fails with the error the stay in the form:

<img alt="" src="/uploads/documents/59/1f/7b/c5/81/d4/aa/e3/4a/00/31/39/e0/07/14/70/591f7bc581d4aae34a003139e0071470.jpeg">

Yes I use mysql, but the file is not supposed to upload the image itself. I increase the max_allowed_packet=16M and now it can upload the rotated images.

But my problem is still than on save, it uploads all the images again. Even the ones not modified. In localhost, it just updates the uri and much faster.

Why it behaves differently?

liias commented 7 years ago

Let's see if I understand your question the same way as you do.

Even if not rotating an image, after uploading an image and saving the ckeditor content it reuploads the image?

aristos32 commented 7 years ago

Yes this is correct. It uploads all images again.

Στις 14 Ιαν 2017 12:55 μ.μ., ο χρήστης "Madis Liias" < notifications@github.com> έγραψε:

Let's see if I understand you question the same way as you do.

Even if not rotating an image, after uploading an image and saving the ckeditor content it reuploads the image?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/liias/imagerotate/issues/1#issuecomment-272616764, or mute the thread https://github.com/notifications/unsubscribe-auth/AQOzOpaZ2UsY_nMqLjPwidSCac_VWFhiks5rSKmdgaJpZM4LjkQE .

aristos32 commented 7 years ago

Ilias, when I save the form, it uploads the images in the database. On my localhost, it just uploads the link, since the image is on the disk. Both cases show uri, just behaves different:

Any hints what to look for?

aristos32 commented 7 years ago

I narrow down the issue. When I upload my images they are in the server:

<img alt="" src="/uploads/documents/59/1f/7b/c5/81/d4/aa/e3/4a/00/31/39/e0/07/14/70/591f7bc581d4aae34a003139e0071470.jpeg">

when I first rotate, the become inline: <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" />

is it possible to keep my images as were, not convert them to data:image?

liias commented 7 years ago

Hey, sorry for not getting back. It seemed very much symfony specific problem. But as I understand you still rotate before image gets to data uri.

Current implementation works like that.

You could do server side post processing and parse image tags, save them as files and change the src, but thats some work, though similar behaviour can be used for pasted images as well.

There are also plugins which seems to support uploading pasted images, like http://ckeditor.com/addon/simpleuploads and http://ckeditor.com/addon/uploadwidget so maybe something useful can be taken from there, but as I personally have solution on server-side you have to do it yourself.

aristos32 commented 7 years ago

Thanks Ilias for your reply. I prefer to use your plugin, since it solves my rotation issue. The situation I have is a matter of image size in the database, especially for big files.

I will give you a real example from my website: I upload an image that has an initial size 632kb. Before uploading it, I resize it, and the size becomes 185kb in the disk in jpeg format. After saving, when I rotate, It becomes data:image/png format, with size increasing to 510kb in the database now. Can this be improved? If rotation kept the original size, it would not cause an issue for me, even stored in the database.