GNOME Bugzilla – Bug 685548
imagecapture x,y offset, height and width parameters are disregarded if window parameter is provided
Last modified: 2012-10-08 19:21:28 UTC
image capture offset, width and height parameters are only used when whole desktop image capture is taken. imagecapture(windowName, outputFile, offsetX, offsetY, captureWidth, captureHeight) When the windowName parameter is provided then whole window capture is taken regardless of what the offsets, width and height parameters are. When the windowName parameter is omitted then the offsets, width and height parameters are respected It works fine when following line in ldtpd/generic.py (line 85) is changed from: x, y, height, width = bb.x, bb.y, bb.height, bb.width to something like this: x, y = x + bb.x, y + bb.y if height > bb.height: height = bb.height if width > bb.width: width = bb.width Thanks.
Fixed the bug in git head, thanks for the bug report with the patch.
Created attachment 226041 [details] [review] Proposed fix to imagecapture() This is how it works: imagecapture() - captures the whole desktop imagecapture(window_name) - captures the window. If the window is over the edge or oversized - clip it. Do not fill with black. Customized capture: imagecapture(x, y, width, height) negative x, y are defaulted to 0 width and height which are less than 1 are defaulted to None - whole window or desktop in that orientation is captured. If x >= width then x = width - 1 If y >= height then y = height - 1 at least one pixel has to be captured.
The fix I proposed is not good. Sorry for that. Now it doesn't work correct if width and height parameters are omitted in the imagecapture() call. I have fixed that in the attached patch. There is few more things I noticed. At the moment it is possible to provide negative offset values. In case of a window it will capture what is around the window. In case of the desktop screen capture it fills the extra space with black color (at least on ubuntu 12.04) Is this a desired behaviour or should it default to 0 if negative values are provided? This also applies to height and width parameters. Captured image should not be bigger than the window/desktop size I haven't really done much with LDTP so far. Is there a use case for that? I have created a patch that assumes only real content is captured (no extra black frame) I hope this is how it should work. If not then please revert the previous commit. It is not good. Thanks.
Once again. Haven't used bugzilla before. Comment 3 should go before comment 2. The original fix (in the bug description is wrong.) The new one should be fine. Sorry once again for the unnecessary extra mails. Regards, Marek
(In reply to comment #4) > The original fix (in the bug description is wrong.) > The new one should be fine. Thanks for the updated patch, fixed it git head > Sorry once again for the unnecessary extra mails. No issues :-) Thanks