FastImage finds the size or type of an image given its uri by fetching as little as needed
12-Aug-2021 1468
Your app needs to find the size or type of an image. This could be for adding width and height attributes to an image tag, for adjusting layouts or overlays to fit an image or any other of dozens of reasons.But the image is not locally stored – it’s on another asset server, or in the cloud – at Amazon S3 for example.You don’t want to download the entire image to your app server – it could be many tens of kilobytes, or even megabytes just to get this information. For most common image types (GIF, PNG, BMP etc.), the size of the image is simply stored at the start of the file. For JPEG files it’s a little bit more complex, but even so you do not need to fetch much of the image to find the size.
FastImage finds the size or type of an image given its uri by fetching as little as needed #ruby #rubydeveloper #rubyonrails #FastImage #finds #image #given #fetching #little #needed #type https://rubyonrails.ba/link/fastimage-finds-the-size-or-type-of-an-image-given-its-uri-by-fetching-as-little-as-needed