compression

Can a JPEG compressed image be rotated without a loss in quality?

时光毁灭记忆、已成空白 提交于 2019-11-29 00:09:16
问题 JPEG is a lossy compression scheme, so decompression-manipulation-recompression normally reduces the image quality further for each step. Is it possible to rotate a JPEG image without incurring further loss? From what little I know of the JPEG algorithm, it naively seems possible to avoid further loss with a bit of effort. Which common image manipulation programs (e.g. GIMP, Paint Shop Pro, Windows Photo Gallery) and graphic libraries cause quality loss when performing a rotation and which

How to Compress a JSONObject send it over Http in Android?

一世执手 提交于 2019-11-29 00:07:27
I am sending a JSONObject to my Webserver from an Android client using the code from this example . Reproducing code here import org.apache.http.HttpResponse; import org.apache.http.client.HttpClient; import org.apache.http.client.methods.HttpPost; import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.params.BasicHttpParams; import org.apache.http.params.HttpConnectionParams; import org.apache.http.params.HttpParams; int TIMEOUT_MILLISEC = 10000; // = 10 seconds HttpParams httpParams = new BasicHttpParams(); HttpConnectionParams.setConnectionTimeout(httpParams, TIMEOUT

How can I enable keep-alive?

冷暖自知 提交于 2019-11-28 23:45:25
问题 I ran a Google Page Speed and it says I scored 57/100 because I need to "Enable Keep-Alive" and "Enable Compression". I did some Google searches but I can't find anything. I even contacted my domain provider and asked them to turn it on, but they said it was already on. Long story short: 1.) What is Keep-Alive? 2.) How do I enable it? 回答1: Keep-alive is using the same tcp connection for HTTP conversation instead of opening new one with each new request. You basically need to set HTTP header

Random access gzip stream

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-28 23:36:07
I'd like to be able to do random access into a gzipped file. I can afford to do some preprocessing on it (say, build some kind of index), provided that the result of the preprocessing is much smaller than the file itself. Any advice? My thoughts were: Hack on an existing gzip implementation and serialize its decompressor state every, say, 1 megabyte of compressed data. Then to do random access, deserialize the decompressor state and read from the megabyte boundary. This seems hard, especially since I'm working with Java and I couldn't find a pure-java gzip implementation :( Re-compress the

How to compress a string?

女生的网名这么多〃 提交于 2019-11-28 23:16:03
I would like to have a reversible compression for a type of string so that i can include it in URLs without keeping track of what it refers to. The string i would like to compress is SVG path string, here is a short primer: http://apike.ca/prog_svg_paths.html Basically, the string contains a character, followed by arbitrary number of integers, then another character followed by arbitrary number of integers and so on. If anyone knows of a good resource for this, it would be much appreciated! Jason olliej Many compression algorithms are well documented, a couple even have js implementations:

Spark: writing DataFrame as compressed JSON

天大地大妈咪最大 提交于 2019-11-28 22:54:12
问题 Apache Spark's DataFrameReader.json() can handle gzipped JSONlines files automatically but there doesn't seem to be a way to get DataFrameWriter.json() to write compressed JSONlines files. The extra network I/O is very expensive in the cloud. Is there a way around this problem? 回答1: The following solutions use pyspark, but I assume the code in Scala would be similar. First option is to set the following when you initialise your SparkConf: conf = SparkConf() conf.set("spark.hadoop.mapred

File compression before upload on the client-side

Deadly 提交于 2019-11-28 22:24:13
问题 Basically I'll be working with large XML files (approx. 20 - 50 MB). These files needs to be uploaded on a server. I know it isn't possible to touch the files with javascript, nor to implement HTTP compression on the client-side. My question is that if any solution exists (flash / action script) that compresses a file and has a javascript API? The scenario is this: Trying to upload 50 MB XML file Before upload a grab it with Javascript and send it to the compressor. Upload the compressed file

Python library for converting files to MP3 and setting their quality

我怕爱的太早我们不能终老 提交于 2019-11-28 21:22:24
I'm trying to find a Python library that would take an audio file (e.g. .ogg, .wav) and convert it into mp3 for playback on a webpage. Also, any thoughts on setting its quality for playback would be great. Thank you. Looks like PyMedia does this: http://pymedia.org/ and some more info here on converting to various formats, whilst setting the bitrate: http://pymedia.org/tut/recode_audio.html e.g. params= { 'id': acodec.getCodecId('mp3'), 'bitrate': r.bitrate, 'sample_rate': r.sample_rate, 'ext': 'mp3', 'channels': r.channels } enc= acodec.Encoder( params ) I wrote a library designed to do that

Make tar file by Java

一世执手 提交于 2019-11-28 21:17:48
I want to use Java to compress a folder to a tar file (in programmatic way). I think there must be an open source or library to do it. However, I cannot find such method. Alternatively, could I make a zip file and rename its extended name as .tar? Anyone could suggest a library to do it? Thanks! You can use the jtar - Java Tar library . Taken from their site: JTar is a simple Java Tar library, that provides an easy way to create and read tar files using IO streams. The API is very simple to use and similar to the java.util.zip package. An example, also from their site: // Output file stream

Compressing a directory of files with PHP

岁酱吖の 提交于 2019-11-28 21:03:56
问题 I am creating a php backup script that will dump everything from a database and save it to a file. I have been successful in doing that but now I need to take hundreds of images in a directory and compress them into one simple .tar.gz file. What is the best way to do this and how is it done? I have no idea where to start. Thanks in advance 回答1: If you are using PHP 5.2 or later, you could use the Zip Library and then do something along the lines of: $images_dir = '/path/to/images'; //this