image-compression

Algorithm to compress jpeg to achieve a specified target image file size

泄露秘密 提交于 2020-05-27 09:24:09
问题 I have a couple of javascript libraries (angular-ahdin, J-I-C), that I can use to compress an image the user uploaded before I submit it to the back end. All libraries I've seen take a quality parameter and use jpeg compression to reduce the file. You have no idea before the compression what file size the resulting image will be, based on any quality value. My idea is to use a "binary search" type algorithm to try different quality percents until I finally get an image that is just under the

Saving an Image stored in BytesIO in pillow

走远了吗. 提交于 2020-02-06 19:37:41
问题 I have an image stored as BytesIO of Pillow and I need to save it to a file with some header information (containing textual attributes) that I need to add specific to my problem. I need the bytes to be represented according to some image compression format. Would that be possible? If yes, how it can be done? I also need to store more than one image in the file. 回答1: Storing more than one image in a file is problematic for PNG, JPEG and the most of the common formats. One option for that is

Image compression is not working

柔情痞子 提交于 2020-01-25 11:34:24
问题 I have an operation on the site that takes crops an image, however the resultant, cropped image is coming out significantly larger in terms of file size (original is 24k and the cropped image is like 650k). So I found that I need to apply some compression to the image before saving it. I came up with the following: public static System.Drawing.Image CropImage(System.Drawing.Image image, Rectangle cropRectangle, ImageFormat format) { var croppedImage = new Bitmap(cropRectangle.Width,

Rotating image increases its size?

痴心易碎 提交于 2020-01-16 05:13:35
问题 I am trying to rotate some images whose width is more than height about the left-top corner, by 90 degrees. I have written this : from PIL import Image import sys, csv, os, traceback, glob import shutil, math src_im = Image.open("Test.png") print src_im.size[0] , ',' , src_im.size[1] src_im = src_im.transpose(Image.ROTATE_90) src_im = src_im.transpose(Image.FLIP_LEFT_RIGHT) src_im = src_im.transpose(Image.FLIP_TOP_BOTTOM) src_im.save("TestResult.png") print src_im.size[0] , ',' , src_im.size

How can we compress images in DAM AEM6.3?

一个人想着一个人 提交于 2020-01-06 06:52:07
问题 We are trying to increase the page score (google) for our website. One of the options to do this is " Image optimization ". As we have a huge number of images in the DAM, how can we compress/optimize them? Does AEM have any such tool to achieve this ? ImageMagick is one of the tool to achieve this. Do we need to integrate that with AEM or we'll have to re-upload all the images after compressing them using the tool? Any suggestions? 回答1: In contrast to CSS, JS and HTML files which can be

How can we compress images in DAM AEM6.3?

怎甘沉沦 提交于 2020-01-06 06:51:09
问题 We are trying to increase the page score (google) for our website. One of the options to do this is " Image optimization ". As we have a huge number of images in the DAM, how can we compress/optimize them? Does AEM have any such tool to achieve this ? ImageMagick is one of the tool to achieve this. Do we need to integrate that with AEM or we'll have to re-upload all the images after compressing them using the tool? Any suggestions? 回答1: In contrast to CSS, JS and HTML files which can be

Android: Compressing images creates black borders on left and top margin

限于喜欢 提交于 2020-01-03 00:24:43
问题 I'm using this compression class from the following site: http://voidcanvas.com/whatsapp-like-image-compression-in-android/ Here is my compression class with very little modifications from the original class: import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Matrix; import android.graphics.Paint; import android.media.ExifInterface; import java.io.FileNotFoundException; import java.io

Android: Compressing images creates black borders on left and top margin

夙愿已清 提交于 2020-01-03 00:23:06
问题 I'm using this compression class from the following site: http://voidcanvas.com/whatsapp-like-image-compression-in-android/ Here is my compression class with very little modifications from the original class: import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Matrix; import android.graphics.Paint; import android.media.ExifInterface; import java.io.FileNotFoundException; import java.io

Combine multer and tinypng API in node

独自空忆成欢 提交于 2020-01-02 17:50:13
问题 does anyone know how to use tinyPNG's API with multer? The docs seem deceptively simple: var source = tinify.fromFile("unoptimized.jpg"); source.toFile("optimized.jpg"); though there's no clear indication of where this is meant to go, especially in something as convoluted as this: var storage = multer.diskStorage( { destination: function (req, file, callback) { callback(null, './uploads'); }, filename: function (req, file, callback) { //use date to guarantee name uniqueness callback(null,

How to convert an image to a base64 string with gzip- android

别等时光非礼了梦想. 提交于 2020-01-01 00:46:07
问题 I am trying to convert and compress an image taken from a filepath on android to be converted with base64's gzip (i am using this because my desktop version, written in java, is doing the same). Here is what I have currently for compression: Bitmap bm = BitmapFactory.decodeFile(imagePath); ByteArrayOutputStream baos = new ByteArrayOutputStream(); bm.compress(Bitmap.CompressFormat.JPEG, 100, baos); byte[] data = baos.toByteArray(); String base64Str = null; ByteArrayOutputStream out_bytes = new