compression

DeflatorInputStream and DeflatorOutputStream do not reconstruct the original data

风格不统一 提交于 2019-11-29 18:39:52
问题 I want to compress some data, so I came across the DeflatorInputStream & DeflatorOutputStream classes. However, the following example shows that I can't seem to reconstruct my original data when using these classes. When I switch to a ZipInputStream and ZipOutputStream it does work, but since I don't need zip files per se, I thought a generic compression would be better. Mainly I'm interested in understanding why this example doesn't work. //Create some "random" data int bytesLength = 1024;

Compress images to reduce file size

风格不统一 提交于 2019-11-29 18:38:29
问题 I'm building an app that lets the user take a photo or select one from the library on the iPhone and upload it to the Parse backend. The problem I'm facing is regarding to the size of the file. I've read about what big players like Facebook, Twitter, Instagram, and Google do regarding resolution and file size but I can't get close to that. I'm sure they have the best code and tools to do that but I'll be happy to implement it as good as possible with iOS regular processes. This is what I'm

How to extract zip file contents into a folder in .NET 4.5

烈酒焚心 提交于 2019-11-29 18:06:32
The following question's answer seems to outline how to extract files using the System.IO.Commpression.ZipFile.ExtractToDirectory method invocation. "ZipFile" doesn't seem to exist in .NET 4.5, when adding a reference to System.IO.Compression. How can I extract files from a *.zip file in .NET 4.5? How to Unzip all .Zip file from Folder using C# 4.0 and without using any OpenSource Dll? This seems to show how to compress files. But I'm looking for the reverse. Zipping files in .NET 4.5 Even this question references "ZipFile" in the source code. But I can't seem to find this class. How to

Compass, config.rb and getting the output actually :compressed

拥有回忆 提交于 2019-11-29 17:56:43
This is my config.rb preferred_syntax = :sass http_path = '/' css_dir = 'css' sass_dir = 'sass' images_dir = 'assets/images' javascripts_dir = 'js' relative_assets = true line_comments = false output_style = :compressed The thing is that the code won't be compressed, sample of few blocks: /* line 37, ../sass/style.scss */ .ui-state-highlight a, .ui-widget-content .ui-state-highlight a, .ui-widget-header .ui-state-highlight a { color: #363636; } /* line 37, ../sass/style.scss */ .ui-state-error, .ui-widget-content .ui-state-error, .ui-widget-header .ui-state-error { border: 1px solid #cd0a0a;

Any theoretical limit to compression?

拈花ヽ惹草 提交于 2019-11-29 17:33:55
问题 Imagine that you had all the supercomputers in the world at your disposal for the next 10 years. Your task was to compress 10 full-length movies losslessly as much as possible. Another criteria was that a normal computer should be able to decompress it on the fly and should not need to spend much of his HD to install the decompressing software. My question is, how much more compression could you achieve than the best alternatives today? 1%, 5%, 50%? More specifically: is there a theoretical

Reducing color depth in an image is not reducin the file size?

こ雲淡風輕ζ 提交于 2019-11-29 16:49:38
I use this code to reduce the depth of an image: public void ApplyDecreaseColourDepth(int offset) { int A, R, G, B; Color pixelColor; for (int y = 0; y < bitmapImage.Height; y++) { for (int x = 0; x < bitmapImage.Width; x++) { pixelColor = bitmapImage.GetPixel(x, y); A = pixelColor.A; R = ((pixelColor.R + (offset / 2)) - ((pixelColor.R + (offset / 2)) % offset) - 1); if (R < 0) { R = 0; } G = ((pixelColor.G + (offset / 2)) - ((pixelColor.G + (offset / 2)) % offset) - 1); if (G < 0) { G = 0; } B = ((pixelColor.B + (offset / 2)) - ((pixelColor.B + (offset / 2)) % offset) - 1); if (B < 0) { B = 0

Is it possible to reload a specific image if it did not finish loading after a preset amount of time? javascript/jquery

核能气质少年 提交于 2019-11-29 15:30:13
I am running a online photography portfolio and sometimes, 1 or 2 images on a page fails to load. and refreshing will display the failed to load image. Scenario: I click on the link and the images start to load. but the page never finishes loading because one of the images fails to load. After a refresh, the browser loads the failed image as a good image. Only a ctrl+F5 can clear the cached failed image. Planned solution: I want to detected images that did not finish loading after 10secs and reload them dynamically using javascript/jquery. I have found a way to force the browser to reload the

Decompress files with .7z extension in java

徘徊边缘 提交于 2019-11-29 15:25:15
Can someone advice (give example) any appropriate and understandable way how to extract file or files with .7z extension basing upon InputStream. I have been examined the XZ for java api, but couldn't succeed. Waiting for any suggestion. This code might help you. import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.RandomAccessFile; import java.util.Arrays; import net.sf.sevenzipjbinding.ExtractOperationResult; import net.sf.sevenzipjbinding.ISequentialOutStream; import net.sf.sevenzipjbinding.ISevenZipInArchive;

Can anyone make heads or tales of this spigot algorithm code Pitiny.c

与世无争的帅哥 提交于 2019-11-29 15:22:16
问题 This C program is just 143 characters long! But it “decompresses” into the first 10,000 digits of Pi . // Created by cheeseMan on 30/11/13. long a[35014],b,c=35014,d,e,f=1e4,g,h; int main(int argc, const char * argv[]) { for(;(b=c-=14); h=printf("%04ld",e+d/f)) for(e=d%=f;(g=--b*2);d/=g) d=d*b+f*(h?a[b]:f/5), a[b]=d%--g; } I was doing some research on loss-less compression algorithms, still no luck yet, when I came across this pitiny.c . The weird thing is that it compiles successfully no

Compress a PNG image with ImageMagick

。_饼干妹妹 提交于 2019-11-29 15:08:50
To compress a JPEG image, I can do: $thumb = new Imagick(); $thumb->readImage("url"); $thumb->setImageCompression(Imagick::COMPRESSION_JPEG); $thumb->setImageCompressionQuality(80); However, I need to also compress PNG images (preserving alpha transparency) to keep sizes down. Is there a way to do it with ImageMagick? pngquant effectively quantizes, or reduces the number of colours in an image till just before there is a discernible drop in quality. You can try something similar in ImageMagick like this... First, using the built-in rose: image, check the number of colours in the image - it is