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
-webkit-transform: not working #220
Comments
There's workaround - not pretty, but still (works for png and jpg pictures). Basic logic: find rotated images, replace their location and provide PHP functionality. Step 1 : include jQuery function which provides CSS transform support. (function ($) {
$.fn.rotationDegrees = function () {
var matrix = this.css("-webkit-transform") ||
this.css("-moz-transform") ||
this.css("-ms-transform") ||
this.css("-o-transform") ||
this.css("transform");
if(typeof matrix === 'string' && matrix !== 'none') {
var values = matrix.split('(')[1].split(')')[0].split(',');
var a = values[0];
var b = values[1];
var angle = Math.round(Math.atan2(b, a) * (180/Math.PI));
} else { var angle = 0; }
return angle < 0 ? angle+360 : angle;
};
}(jQuery)); Step 2 : replace location of rotated images with PHP URL (include this before html2canvas render). $("img").each(function(){
rot = $(this).rotationDegrees();
if (rot != 0)
$(this).attr("src", "/rotateimg.php?rotate=" + rot + "&loc=" + $(this).attr("src"));
}); Step 3 : create rotateimg.php which provides rotate functionality <?php
$loc = $_GET['loc'];
$rot = -$_GET['rotate'];
$path = "/web/images/path"; // $_SERVER['DOCUMENT_ROOT'] ?
$source = NULL;
if (substr($loc, -3) == "png")
$source = imagecreatefrompng($path . $loc);
else if (substr($loc, -3) == "jpg") {
$source = imagecreatefromjpeg($path . $loc);
}
imagealphablending($source, false);
imagesavealpha($source, true);
$img = imagerotate($source, $rot, imageColorAllocateAlpha($source, 0, 0, 0, 127));
imagealphablending($img, false);
imagesavealpha($img, true);
imagepng($img);
?> I hope it helps. =) |
I've added support for images rotated by 90, 180 or 270 degrees. https://github.com/mjaggard/html2canvas/tree/simple-rotation Non-image rotation is not generally supported and nor are other transformations (although I some translations and rotations are supported by html2canvas anyway because it lets the browser do the work). |
Subscribing. Looking for a better rotation solution for images/html here as well. We need -webkit-transform to work with "degrees", not this matrix stuff though. Thanks |
Greetings, What about scaling? I have a scaled text that doesn't renders properly; the characters get all cramped together. Can anyone point me to the right direction for maybe implementing this scaling feature? |
I need rotate :( |
The implementation of transform scale would be great. I think it is a really important point, because you are able to increase font- and image-quality. If you render for a example a text and zoom with the browser, the quality is really bad. That could make your html2canvas-plugin also useful for text-editors and so on. @niklasvh : Do you plan to implement this feature in near future? I would appreciate that and would give u a donate for that. |
Hi, this feature really miss this excellent tool, any plan to this feature ? |
@mjaggard - is there any chance your image rotation code can be integrated in the recent version of the library? |
Hi, Do you plan to add this feature soon ? Thanks a lot ! |
Hi, .rt{-ms-transform: rotate(7deg); /* IE 9 / On Wed, Jan 7, 2015 at 7:02 PM, dscarteland notifications@github.com
|
@liteelips me too, i also need text rotation :( |
Does anyone find any solution for rotated divs screenshot? |
+1 |
Full working code with rotation and transform for all browser. Can't attach the file. Mail me to collect the file arindamm@indusnet.co.in |
Awesome, thank you! Have you considered making a pull request or putting on JS Fiddle? |
hi , On Tue, Sep 29, 2015 at 3:32 PM, Arindam Mojumder notifications@github.com
Amar Singh Email: amar.singh@kodework.com caleb@kodework.com |
Hi, I am also struggling to get transforms (rotate) to work, specifically in IE. The finished canvas does in fact contain a rotated element, but typically only half of the element is shown. |
This is the style of the script:
// Html to Canvas and saving image to backendhtmlToCanvas.js file (function($){
})(jQuery); |
Updated with background image and svg graphics. // Html to Canvas and saving image to backend
})(jQuery); |
css rotation and Transform does not work perfectlly ...I have these stuff in my code |
I have used matrix for this. try this one. On Thu, Oct 15, 2015 at 1:57 PM, Yo Yo notifications@github.com wrote:
Note: We will be off for Durga Puja With best regards Indus Net Technologies http://www.indusnet.co.in Rated #1 IT SME in India - 2008 by Dun & BradstreetGtalk : arindamm@indusnet.co.in skype : arindam_mojumderMob:+919830307843,+918420200614 Fax : +1-760-284-6062This message contains information that may be privileged or confidential |
@arindamm which one ? can you send me the updated file . |
@arindamm : If you are talking about the above code than where to add it exactly. |
already added, check the attached js file in my previous mail. On Thu, Oct 15, 2015 at 3:52 PM, Yo Yo notifications@github.com wrote:
Note: We will be off for Durga Puja With best regards Indus Net Technologies http://www.indusnet.co.in Rated #1 IT SME in India - 2008 by Dun & BradstreetGtalk : arindamm@indusnet.co.in skype : arindam_mojumderMob:+919830307843,+918420200614 Fax : +1-760-284-6062This message contains information that may be privileged or confidential |
sorry. On Mon, Oct 19, 2015 at 3:45 PM, Ranga notifications@github.com wrote:
Note: We will be off for Durga Puja With best regards Indus Net Technologies http://www.indusnet.co.in Rated #1 IT SME in India - 2008 by Dun & BradstreetGtalk : arindamm@indusnet.co.in skype : arindam_mojumderMob:+919830307843,+918420200614 Fax : +1-760-284-6062This message contains information that may be privileged or confidential |
I didn't work in that part. Sorry to say I can't help. you can make your On Thu, Oct 29, 2015 at 11:12 AM, Yo Yo notifications@github.com wrote:
With best regards Indus Net Technologies http://www.indusnet.co.in Rated #1 IT SME in India - 2008 by Dun & BradstreetGtalk : arindamm@indusnet.co.in skype : arindam_mojumderMob:+919830307843,+918420200614 Fax : +1-760-284-6062This message contains information that may be privileged or confidential |
you can do a workaround which is told here: |
Guessing this still hasn't been looked at. Kind of needed translateY to work for vertical aligning (would have hoped this would have been a simple implementation but obviously not). 👍 |
img = document.createElement("img")
img.src = canvas.toDataURL()
newCanvas = document.createElement('canvas')
ctx = newCanvas.getContext("2d")
newCanvas.height = 350
newCanvas.width = 200
ctx.translate(185, 35)
ctx.rotate(90 * Math.PI/180)
ctx.drawImage(img,0,0); #draw it
canvasURL = newCanvas.toDataURL() From html2canvas, I get canvas. I then use the above javascript to create a newCanvas which is rotated 90 degrees. use height, width, translate property according to your use case |
The box-shadow css3 is not working ? But still thank you |
Transforms are partially supported in 1.0.0 |
@niklasvh Any info on exactly which transforms are and are not supported? |
rotate seems not working |
The transfor css is not working.
img class="imageobject" id="3" src="images/large/food.png" style="-webkit-transform: matrix(0.5, 0.42, -0.42, 0.5, 120, 52);"
I need this feature badly. I have tried to edit your code by implementing the matrix, but failed.
I have worked this this function
function renderImage(ctx, element, image, bounds, borders, matx) {}
Here I have passed one more parameter "matx". It is the matrix value of that image. But can't assign this matrix to the "ctx".
The same issue is happening for text field also.
Please help me.
The text was updated successfully, but these errors were encountered: