location / coordinates of images on canvas
See original GitHub issueI’m trying to find the x,y,width,height of images on the canvas, similar to the div/span text layer. I would also like a separate image file as well. I’m going to do two things with this for academic articles: scroll to figures after clicking a link and show the images in a separate gallery. In the svg:img, I see there is a url which shows only the image with it’s original size, is there a way to get that url without searching through the svg object? The images in the svg are placed on the page using a series of transforms. Is there a way to get the x,y,width,height without measuring the size of the rendered svg:img?
// get svg which contains img elements
const opList = await page.getOperatorList()
let svgGfx = new pdfjsLib.SVGGraphics(page.commonObjs, page.objs);
svgGfx.embedFonts = true;
const svg = await svgGfx.getSVG(opList, viewport) // image url in svg:img elements
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:10 (1 by maintainers)
Top Results From Across the Web
How to get coordinates x y of image in a canvas - Stack Overflow
I want to get the coordinates x,y of my picture inside this canvas even if I zoom on it or drag it. javascript...
Read more >HTML Image Map in Canvas
Discover an amazing HTML image mapping technique! ... All the coordinates are based on the upper left corner of the map, which is...
Read more >HTML Canvas Coordinates - W3Schools
Canvas Coordinates. The HTML canvas is a two-dimensional grid. · Coordinates Example. Mouse over the rectangle below to see its x and y...
Read more >HTML image map in Canvas - YouTube
Convert your uploaded image into an interactive map of hotspots. This is a fantastic way to create dynamic content in your Canvas course...
Read more >Use the Go-to Coordinate tool—ArcGIS Excalibur
A location pin centers and pans in the Map Focus Panel. If the Image Focus Panel is open, the location pin will center...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Basically each
paintImageXObject
op was preceded by atransform
op and that transform op had a corresponding args which were six numbers two last of which were the X and Y coordinates. I think this will be true for many PDFs.https://github.com/TomasHubelbauer/puppeteer-globus-scraper/blob/master/index.mjs#L63
I also found this code:
It can get the Uint8ClampedArray of imagedata but it is divisible by 3 (therefore rgb) rather than 4 (rgba: what canvas wants). Adding the alpha channel in a loop seems slow, is there a faster way? Seems like this ‘search the ops list’ approach might have the img x,y,width,height, but still not sure how to get at that.