Giter Site home page Giter Site logo

awsfileuploaderwithimagecompression's Introduction

Build Status LinkedIn

AWSFileUploaderWithImageCompression

A library for compressing, adding watermark and uploading the file into aws s3.

This library uses Magic.NET for compressing and adding watermark to the image.

Features

  • Compress the image in a simplied way.
  • Seperation of logic for uploader, compression and adding watermark.
  • Save s3 bucket space by compressing the image before uploading it.

Installation

Usage

⚙️Using the image service class

  //Initialize the s3imageuploader with respective access_key, secret_key and the bucketname
  IS3ImageUploader s3ImageUploader = new S3ImageUploader("ACCESS_KEY", "SECRET_KEY", RegionEndpoint.APSouth1, "BUCKET_NAME");
  IImageService imageService = new ImageService(s3ImageUploader);
  PutObjectResponse objectResponse =  await imageService.CompressAndUploadImageAsync(System.IO.File.OpenRead("C:/myfolder/mypic.jpg"), "newname.jpg" /* Optional to provide a new filename by default it uses Guid for the uploaded filename.*/); 

⚙️Using the individual classes

ImgCompressorConfiguration imgCompressorConfiguration = new ImgCompressorConfiguration
{
    MaintainAspectRatio = true,
    MaxHeight = 600, //Default is 1200
    MaxWidth = 800, //Default is 1600
    WaterMarkPosition = ImageMagick.Gravity.Northeast, //Default is Southeast (bottom right)
    WaterMarkTransperency = 5 //The watermark transperency ranges from 0 to 10, 0 as 0% and 10 as 100% transperency.
};
IImageCompressor compressor = new ImageCompressor(imgCompressorConfiguration /* Optional */);
//For adding watermark to the image
bool watermarkSucess = await compressor.AddWaterMark("C:/myfolder/mypic.jpg", "C:/myfolder/icons/watermark.png",
    "C:/myfolder/output/myimage.jpg");

//For compressing the image (Note: The compression will happen when the source image exceeds the MaxHeight or MaxWidth configuration.
ImageCompressorResponse compressionSuccess = await compressor.CompressImage("C:/myfolder/mypic.jpg", "C:/myfolder/output/myimage.jpg");
/* The response will have the following data :
 * 1. ImageCompressionSucccess
 * 2. OriginalSizeInBytes
 * 3. OriginalImageWidth
 * 4. OriginalImageHeight
 * 5. AfterCompressionSizeInBytes
 * 6. ResizedImageHeight
 * 7. ResizedImageWidth
 * 8. OutputFilePath
 * 9. OutPutFileStream (If output was provided as a stream)
 */

Contributing

Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated. Feel free to request for any changes or any additional features.

License

Distributed under the MIT License. See LICENSE for more information.

Contact

Name: Muthukumar Thevar

Email: [email protected]

Project Link: https://github.com/mak-thevar/AWSFileUploaderWithImageCompression

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.