w := 1900
h := 1200
divisor := gcd(w, h)
aspect := fmt.Sprintf("%d:%d", w/divisor, h/divisor)
func gcd(x, y int64) int64 {
for y != 0 {
x, y = y, x%y
}
return x
}
This. I work in media. Just passed this along to a few designer friends, and even non-designers who work with magazine design teams and regularly have to translate images and resize/crop them for mobile and web.
edit: They're already happy to have it in their back pocket.
Yeah, this is really more of a reference and a tool when you’re comparing sizes and confirming they are the same aspect ratio without having to use code. There’s also an NPM module that will do the code part if you need to go that route.
I just looked at Responsive Design Mode in Firefox Developer Tools and they also have a list of 16 devices with resolutions (Chrome has 29). There is a lot of overlap in the two lists, but using those would tie into a common tool we use to view sites on different devices.
Yeah, probably doesn't. I just found myself using it across a couple different projects and seemed like it would be easier than having to copy and paste it everywhere.
Also, it has a command line tool that you can use to get the aspect ratio from width/height. So, not just the code.