I’m using cropit.js to allow a visitor to upload a large JPEG or TIFF image which is intended for print. I print at 300DPI.
The dimensions of the cropit.js HTML 5 canvas are determined by the visitor (using a numberfield in a previous script, these dimensions are passed as a var to the cropit.js HTML 5 canvas. This all works great.
Some images will not initially be suitable or require resizing by the visitor. Cropit.js should be great for this.
My query: I’d like to show the effective size of an uploaded image, its size in comparison to the HTML 5 Canvas (which is a representation of the final printed image @ 300DPI). The maths / calculations required blow my mind. Can anyone help?
- Can code detect screen DPI? No it seems not.
- Can a calculation be done to show the effective print size? Seems not.
- What maths do I require to display an emulated size (taking into account the resolution of the uploaded image), and the dimensions entered by a visitor?
This can be easily exemplified in Photoshop, where you make a 'canvas' (photoshop canvas size) of say, 210 x 210mm at 300DPI. If you then drop a 1000x2000px image of 72DPI into the canvas... it doesn't quite work, user either has to upsize, and crop. This is the functionality I'd like to mimic with cropit.js
<script>
$(function() {
$('.image-editor').cropit({
imageState: {
src: 'imagedir/image1000x2000px.jpeg',
},
});
$('.preview-wrapper').cropit('previewSize', { width: ''+ var_numberfield_width+'', height: ''+var_numberfield-height+'' });
$('.export').click(function() {
var imageData = $('.image-editor').cropit('export');
window.open(imageData);
});
});
</script>
As I work on a complete answer I thought I might bring together a load of links I'm finding interesting reading. Might be helpful in future: