When we load an image and it’s onload handler runs, is it guaranteed that the width and height is at least one?
var img = new Image();
img.onload = function(){
// is img.width and img.height guaranteed to be at least 1?
// can we do something like assert img.width >= 1 && img.height >= 1
};
img.onerror = function(){
alert("error");
}
img.src = 'MyImage.png';
Basically, I was wondering is it even possible for a loaded image to have a width or height of 0?
Or rather, is there even an image extension (gif, png, svg, jpg, exif, raw, bmp, tiff, etc) that supports 0 width or 0 height images?
I don’t know of a single raster image encoding format that supports image widths of zero. SVG might be able to, or perhaps another vector format, but no raster format would.