-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Specify output image dimensions #21
Comments
+1 This would certainly be an enhancement |
Could you not wrap the cloned dom node in a wrapper div and then start the transform process? I was working on my own zoom function for something else the other day and the transform property worked OK for text and not so great for images/graphics. |
I think |
+1. This would be a useful feature for creating thumbshots with consistent width/height irrespective of browser width.
Although for me this doesn't produce exactly the same result for different browser widths at the moment due to (Bootstrap's) media queries. It would be good if |
Hi, with recently added |
Looks great, thanks tsayen! I cant find any examples on how the style option works. I'm trying to double the size of the output but I'm not sure what syntax is expected:
|
|
Thanks. It's a clever solution and it would work well but there is still an issue unfortunately. Is it possible to move the code that draws the output image boundaries, to after the new styles have been applied? If the boundries of the element are changed by the new styles, the resulting image remains the old size. For example, |
Maybe try also to add |
I looked into this a bit more and I think using JS If we use getBoundingClientRect() instead to get the node's width & height, it should return the real dimensions after scaling/transforms, etc. |
concerning the |
Thanks for looking into this tsayen, That is more or less what I have but I have a line of centered text outside the grey box which is to be included in the image. I made a quick fiddle to show how I tried replacing all instances of Have you any idea why it might be reducing the size after calculation? If I run |
take a look at this jsfiddle - does it do what you want? |
Almost. Mine is more like this. It should really just scale the dom node exactly without any restyling. |
that's a strange behavior (I mean the scaled text overflows). But if you wrap it into a div, the problem is fixed |
Thanks I'll try putting a wrapper on it in the morning and see if it works. If so, it might work well to do it from the src code - wrap everything in a div before rendering |
Hi tsayen, Can I suggest you add one more rendering option called "scale" which automatically sets these settings for users? It's a very powerful feature to be able to render DOM nodes at any resolution and as we have seen, this feature is not obvious or easy to use. Here's my final, working function for downloading a scaled image, in case someone else wants to use it: (FileSaver.js is required)
|
Hey, glad it worked for you :) The feature you're suggesting absolutely On Tue, Apr 26, 2016 at 11:37 AM, cronoklee notifications@github.com
|
Width, height, and style options are nice; but would love if we could render that image at specific browser width without having the user resize their browser (so media queries can be provided). html2canvas has this; but your library is faster and cleaner; but I cannot port from html2canvas unless I have a way to render the image with a certain width and also it would be great if we could render with media = printl |
Had some issues to generate 10x bigger jpeg file, but it's finally working ;) Thank you! My code:
}` |
How to increase the domnode size which we have captured through findDomNode? |
It would be extremely useful to be able to optionally specify the dimensions for the output image and have the image rendered at a higher resolution than the DOM element itself.
This would have numerous uses but would be particularly useful for printing the image afterwards. Printing at 72dpi (screen resolution) is not advisable!
One simple idea for making this happen is to scale the DOM element before rendering using the CSS *_zoom *_property or the CSS *_transform *_property. I attempted this but the bounding box for the element seems to remain the same, so while the elements do render larger, as expected, the image itself is cropped to the original size of the element, cutting out the bottom and right part of the element.
The text was updated successfully, but these errors were encountered: