Wednesday, August 30, 2023
HomeiOS Developmentios - HTMLCanvasElement.toDataURL() JPEG high quality completely different on Apple and Home...

ios – HTMLCanvasElement.toDataURL() JPEG high quality completely different on Apple and Home windows


I’ve a canvas, in reminiscence, not a part of the DOM, that I write picture bytes to. The picture measurement is 1008 x 756 (a 4032×3024 photograph lowered to 1/4 measurement). I then name canvas.toDataUrl('picture/jpeg',.8) to output a JPEG picture at 80% high quality. On home windows, the ensuing file is 204 KB. On Apple (iPhone, iPad, and Mac) the ensuing file is over 300 KB. With a purpose to create a file of comparable storage measurement, I would like to make use of a top quality worth of .528 on Apple to match a .8 worth on Home windows. And for .9 on Home windows, a price of .648 is required on Apple.
I might have thought that every one JPEG libraries could be customary throughout all platforms and that the “high quality” worth could be customary throughout platforms and browsers and in all implementations. Has anybody else run into this difficulty? Does anybody have an equation to match qualities throughout platforms or different resolution?

perform ConvertImageToJPEG( picture )
{
    var width     = 1008;
    var top    = 756;
    var canvas    = doc.createElement( 'canvas' );

    canvas.width  = width;
    canvas.top = top;

    var context   = canvas.getContext( '2nd' );

    context.drawImage( picture, 0, 0 );

    return canvas.toDataURL( 'picture/jpeg', .8 );
}



Supply hyperlink

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments