<< More Tutorials
How to resize an image by height in Kotlin using rethumb?
To resize an image or photo in Kotlin use the following code:
import java.io.FileOutputStream
import java.net.URL
import java.nio.channels.Channels
object KotlinRethumbHeightExample {
@Throws(Exception::class)
@JvmStatic fun main(args: Array<String>) {
val paramOperation = "height"
val paramValue = 100 // New height in pixels.
val imageURL = "http://images.rethumb.com/image_coimbra_600x300.jpg"
val imageFilename = "resized-image.jpg"
val url = URL(String.format("http://api.rethumb.com/v1/%s/%s/%s", paramOperation, paramValue, imageURL))
val fos = FileOutputStream(imageFilename)
fos.channel.transferFrom(Channels.newChannel(url.openStream()), 0, java.lang.Long.MAX_VALUE)
}
}
Start using this example now
Use the following commands to get started:
$ git clone https://github.com/rethumb/rethumb-kotlin-examples.git
$ cd rethumb-kotlin-examples
$ kotlinc resize-by-height.kt -include-runtime -d resize-by-height.jar
$ java -jar resize-by-height.jar
More examples using Kotlin
How to use rethumb in Kotlin?
How to resize an image by width in Kotlin using rethumb?
How to resize an image by height in Kotlin using rethumb?
How to resize an image by width and height in Kotlin using rethumb?
How to create a square thumbnail from an image in Kotlin using rethumb?
How to read Exif data in json format from an image in Kotlin using rethumb?
How to make an image responsive in Kotlin using rethumb?
How to read GPS coordinates from an image in Kotlin using rethumb?
How to convert an image to JPG, GIF, PNG, TIF or WebP in Kotlin using rethumb?
How to resize an image to cover any dimensions in Kotlin using rethumb?