Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

toDataUrl exports are automatically scaled up and cropped on 1.6RC #2744

Closed
shlomokraus opened this issue Jan 19, 2016 · 14 comments · Fixed by #2806
Closed

toDataUrl exports are automatically scaled up and cropped on 1.6RC #2744

shlomokraus opened this issue Jan 19, 2016 · 14 comments · Fixed by #2806
Labels

Comments

@shlomokraus
Copy link

When I use toDataUrl on a canvas, it exports the image scaled up and cropped.
It has the same behaviour even if I set multiplier, size or top/left position.

Reverting back to 1.5 fixed the issue.

@asturur
Copy link
Member

asturur commented Jan 19, 2016

can you post a fiddle that demonstrate the problem? thanks.

@ahmadissa
Copy link

facing same issue with 1.6RC, the strange thing is that it happens only when using my windows 10 laptop, it does not happen when using my ubuntu, both using the latest chrome. im not sure if its related to graphics capability of the laptop

@ahmadissa
Copy link

Solved in the below way:

var fabricJScanvas = new fabric.Canvas('"myCanvasID");

Used:
var canvas = document.getElementById("myCanvasID");
canvas.toDataURL('image/jpeg', 0.92);

instead of:
fabricJScanvas.toDataURL('image/jpeg');

I dont know how this make scene, but its working.

@asturur
Copy link
Member

asturur commented Jan 19, 2016

you did not solve, you avoided calling the dataUrl exporter.
A fiddle is needed to test it.
Anyone willing to prepare it?

@AdamMerrifield
Copy link
Contributor

@asturur Here is an interesting example I just added to the toDataURL demo jsFiddle link and updated the fabric.js external resource to 1.6.0-rc.1

You can see the canvas and how it gets rendered and then in the console you can see a couple data uri's, none of which look correct (except the last one which avoids the dataUrl exporter like above.)

@asturur
Copy link
Member

asturur commented Jan 25, 2016

They all look correct to me except for the cropped one of which cannot guarantee correctness using only eyes.
All others are fine.

I'm using windows 8.1 and chrome.

When i move in the windows 10 laptop i will test again. with chrome and edge.

@AdamMerrifield
Copy link
Contributor

Here is an album of each of these images that i'm getting. On windows everything comes though correct, but on a mac it's wrong.

Mac Version 10.11.3 (15D21)

Google Chrome Version 47.0.2526.111 (64-bit)

same thing happens on:

Safari Version 9.0.3 (11601.4.4)

@asturur
Copy link
Member

asturur commented Jan 25, 2016

You are getting the "retina enanched" version of the canvas. that is correct yes.

When we prepare the canvas for toDataUrl we should reset the retina scaling maybe. This is a bug i will have tons of problem to iron out.

@AdamMerrifield
Copy link
Contributor

Looks like you're correct. Setting enableRetinaScaling: false on the canvas fixes this problem for me.

@asturur
Copy link
Member

asturur commented Jan 25, 2016

@kangax what do you think, a mac user, should expect when dataurling his fabricjs canvas?

To get the normal version everyone gets or to get the retina scaled version?

because this decision influence the fix.

@kangax
Copy link
Member

kangax commented Jan 26, 2016

I think retina version.

@asturur
Copy link
Member

asturur commented Feb 24, 2016

Someone care to try #2806? it fixes retina export of canvas to dataUrl.

@AdamMerrifield
Copy link
Contributor

@asturur Everything looks correct to me now (the 600px canvas is giving me 1200px images which is correct for mac). I've only checked a mac though, can someone check a PC? See if all the images corrospond to the ones I'm seeing Here is an fiddle with the new js from your pull request and Here is an album of each image.

@asturur
Copy link
Member

asturur commented Feb 25, 2016

i'm on pc and it looks correct for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants