These are chat archives for openseadragon/openseadragon

17th
Nov 2015
David
@davepruitt
Nov 17 2015 05:26
Hey all, for the app that I am creating, I would like to add a feature that allows the user to save certain parts of the image as smaller PNG files. I am using a Deep Zoom source (the original Deep Zoom image is about 186,000 pixels by 87,000 pixels). Currently, I allow the user to draw rectangular overlays over certain parts of the image. I would now like the user to be able to save these "outlined" segments of the image as PNGs (but at a much lower DPI of course...I don't want to save these at their raw resolution). I have found "pngjs" which seems to be a good library for encoding PNG files in Javascript. I just need to be able to access the actual pixel data in the underlying DZI source. If I have a Rect that outlines the area I'd like to "save", what is the best way to get at the underlying raw image data?
Matthias Guth
@ChiSamurai
Nov 17 2015 08:24
@iangilman : thanks for your answer :) since I need that functionality for my project, I'll have to create a function like that. atm I'm thinking of getting the absolute position of the OSD container, using the abspos - mouse.pageXY delta, calculate the image pixel using the zoom or scale factor and then compute the rotation into this (yet I have to think about that :) ). Would this be a suitable way to go or could you point me to the codelines in OSD source so that I (or maybe a colleague) can have a deeper look?
Ian Gilman
@iangilman
Nov 17 2015 17:08
@davepruitt You can access the viewer's html canvas via viewer.drawer.canvas or viewer.drawer.context, and you can copy the pixels out of there as needed.
Ian Gilman
@iangilman
Nov 17 2015 21:31
@ChiSamurai Sounds reasonable... viewportToImageCoordinates and getRotation should be what you need to work with.