Developing my first R package, tinieR was one of the most rewarding projects I’ve done this summer (and I’ve been busy). So much so that I couldn’t stop tinkering with it; and so now here’s tinieR 0.2.0, with added resize ability and more choice in how it returns the newly tinified file path!
You can now use the
resize argument to change the image dimensions along with its file size. I recommend reading the TinyPNG API documentation on resizing methods first, to familiarise yourself with the various options you can use to change image dimensions.
resize takes a named list, containing a
method string and at least one of
height, or both
height depending on your chosen resize method, to specify the dimensions in pixels you would like the image resized:
tinify("imgs/example.png", resize = list(method = "fit", width = 300, height = 150))
This should work fine alongside all existing options, like
New return_path options
Instead of just returning the absolute file path of the newly tinified file, you can now choose to have it returned as an absolute file path, a relative file path, or a list of the two!
return_path = "abs" to return the absolute file path to the tinified file as before. Set to
return_path = "rel" to return the file path relative to the working directory at the time the file was tinified. This may be useful if sharing a script with others across platforms, if you can be sure your project setups will be the same and you are being strict with working directories!
Finally, set to
return_path = "all" to return both types of file path as a named list:
shrunk_img_list <- tinify("imgs/example.png", return_path = "all")
I hope these new options are useful - they at least seemed like things I wanted when I was using the package myself! You can see full details at the tinieR package Github repo where the update is available for download now 🔥