1. Products
  2.   Image
  3.   GO
  4.   Picfit
 
  

Open Source Image Resizing Server that Provides Faster Processing

Picfit is an image resizing server developed in Pure Go that takes care of storage part of image processing no matter the storage engine used.

What is Picfit?

Image processing, particularly resizing operations, can become a significant bottleneck in an application's performance. This slowdown often occurs when user avatars and other images are stored across different storage engines, forcing the application to handle complex retrieval codes and make multiple synchronous calls to fetch processed images. Picfit elegantly resolves these challenges by serving as a high-performance proxy situated directly between your chosen storage engine and your HTTP cache layer.

As a free, open-source image processing engine, Picfit delivers faster processing while intelligently managing your storage footprint. Its core architecture prevents the system from generating duplicate images, ensuring the same resized version is never created twice, which saves both processing time and valuable disk space. The solution offers versatile compatibility, allowing you to seamlessly store and serve your original images from various backends including Amazon S3, DigitalOcean Spaces, a local file system, and other popular storage services.

Previous Next

Getting Started with Picfit

The easiest and recommend way to install Picfit is via GitHub. Please use the following command for an easy and smooth installation.

Install Picfit via GitHub

 git clone https://github.com/thoas/picfit.git

Resize Images via Free GO Library

The open source picfit library enables software developers to programmatically resize images inside their own application using Go commands. One of the main function of Picfit is the ability to resize images according to the height and width of your choice. Simply provide the w (the desired image’s width) and h (the desired image’s height) values.  

How to Resize Image via Free GO Library?

 func (e *GoImageEngine) Resize(img *imagefile.ImageFile, width int, height int, options *Options) ([]byte, error) {
	if options.Format == imaging.GIF {
		content, err := e.TransformGIF(img, width, height, options, imaging.Resize)
		if err != nil {
			return nil, err
		}
		return content, nil
	}
	image, err := e.Source(img)
	if err != nil {
		return nil, err
	}
	return e.resize(image, width, height, options)
}

Free Go Library to Genrate Thumbnails

You can use this function to generate a new image with a resampled filter either scaled up or down, and crops it to a specified height and width. Again in this function you have to provide the w and h values.

How to Genrate GIF Thumbnails inside GO Apps?

func (e *GoImageEngine) Thumbnail(img *imagefile.ImageFile, width int, height int, options *Options) ([]byte, error) {
	if options.Format == imaging.GIF {
		content, err := e.TransformGIF(img, width, height, options, imaging.Thumbnail)
		if err != nil {
			return nil, err
		}
		return content, nil
	}
	image, err := e.Source(img)
	if err != nil {
		return nil, err
	}
	return e.thumbnail(image, width, height, options)
}

Reterive Image Infomation via Go API

Apart from resizing functions, Picfit also has some important functions to retrieve file information like Get, as well as storage or uploading commands. With the Get function you will get the following parameters as a result:

  • File name: name of the generated file
  • Path: this will be the path of your generated file on your storage engine
  • URL: if the base_url is present then you will receive a full URL of your generated file
 English