vokal/vip

Include image dimensions in the filename

Closed this issue · 7 comments

I just discussed this with @scottferg: in some apps, it's helpful to know the aspect ratio of an image before downloading it, so the UI layout can be figured without having to wait for large images to download first. We eventually settled on a simple solution: include the original dimensions of the image in the random filename that's generated. So, for an image that's 1242 wide and 2208 tall, the filename might be ef13692177557cb6bbfd34241e0c6ad2-1242x2208. Since the app knows the URL to request for the photo, it can pull the dimensions out of that URL to determine how big the image will be once resized to the desired width.

@scottferg This requires reading the file data on the server to get the image size before sending it to S3; How concerned are we about any performance hit here?

Measure it and find out. Won't know the impact until we get in and start digging.

Would the best way to do that be adding a benchmark to upload_test.go? Then run before and after?

I would add a benchmark, but also run the server locally and throw in just basic timestamps to measure the latency.

You will likely be able to optimize the performance impact away, but the more metrics you can give yourself the better

Any movement on this one?

I have some code in progress; I'll try and wrap it up tomorrow. I haven't made much progress since I was trying to work out how best to benchmark any performance regressions.