1. Products
  2.   Image
  3.   Java
  4.   Glide
 
  

Open Source Library for Image Processing in Android

A Free Java Library that allows software developers to Fetch, Decode & Display Images like GIF, PNG, JPEG, BMP and more in Android applications.

Glide is an open source very powerful well-designed Java library for image loading and manipulation. The library enables computer programmers to add, delete and display their images inside Android applications. Moreover, it also allows developers to make changes to particular data while limiting access to fields that should not be changed. The library supports popular image formats like JPG, PNG, GIF, and SVG.

Glide makes it easy for the programmers to add, host, and display images in their Android application with just a little effort and cost. It allows adding images from the web or uploads their own images and even use images from within their projects. The library allows users to customize their images in different ways, such as show image without cropping, crop images according to your needs, setting image height and width, and many more.

Previous Next

Getting Started with Glide

Building Glide with Gradle is fairly straight forward: You can easily install the Gradle library via GitHub. Please use the following command.

Use Glide via Gradle

repositories {
  google()
  mavenCentral()
}

dependencies {
  implementation 'com.github.bumptech.glide:glide:4.14.1'
  annotationProcessor 'com.github.bumptech.glide:compiler:4.14.1'
}

Install Glide via GitHub

 git clone https://github.com/bumptech/glide.git  

How to Rotate Image via Java

The open source Glide library has provided complete functionality for loading and rotating images inside Android applications. The library makes it easy to load an image from a remote location. Glide enables software developers to rotate an image to a specific angle with just a couple of lines of code. It is also possible to dynamically set it to how many degrees the image is going to be rotated.

Use Glide via Gradle

private void loadImageOriginal() {  
    Glide
        .with( context )
        .load( eatFoodyImages[0] )
        .into( imageView1 );
}

private void loadImageRotate() {  
    Glide
        .with( context )
        .load( eatFoodyImages[0] )
        .transform( new RotateTransformation( context, 90f ))
        .into( imageView3 );
}

Load Images in Custom Size in Android

The open source Glide library has included a very unique feature enabling software developers to request images in particular sizes or dimensions from their servers. In today's advanced media era, mostly media servers are storing and provided images in a very high resolution. But in most cases, it may not be considered very efficient regarding the device's bandwidth, memory, and battery. The Glide solves this problem by measuring the dimensions of the image and sending a request to the server for custom size and thus the server will provide the image in a specific size. Please remember that you will need to enable the support from the server side.

Load Images in Custom Size

public class CustomImageSizeModelFutureStudio implements CustomImageSizeModel {  
    String baseImageUrl;

    public CustomImageSizeModelFutureStudio(String baseImageUrl) {
        this.baseImageUrl = baseImageUrl;
    }

    @Override
    public String requestCustomSizeUrl(int width, int height) {
        
        // new way, server could handle additional parameter and provide the image in a specific size
        // in this case, the server would serve the image in 400x300 pixel size
        // https://futurestud.io/images/logo.png?w=400&h=300
        return baseImageUrl + "?w=" + width + "&h=" + height;
    }
}

Scale & Resize Images inside Android

The open source Glide library has provided complete support for various transformation features. It makes it easy for the developers to make adjustments to the image size and display it. It can be used to change image size, bounds, image colors, pixel positioning, and much more. The Glide library is very efficient regarding memory-wise as it automatically limits the size of the image it holds in cache and memory to the ImageView dimensions. It provides support for both Explicit and Implicit image scaling inside Android apps.

Scale & Resize Images inside Android

 Glide  
    .with(context)
    .load(UsageExampleListViewAdapter.eatFoodyImages[0])
    .override(600, 200) // resizes the image to these dimensions (in pixel)
    .centerCrop() // this cropping technique scales the image so that it fills the requested bounds and then crops the extra.
 English