jpeg

python file I/O with binary data

自闭症网瘾萝莉.ら 提交于 2020-01-23 19:42:09
问题 I'm extracting jpeg type bits from mp3 data actually it will be album arts. I thought about using library called mutagen, but I'd like to try with bits for some practice purpose. import os import sys import re f = open(sys.argv[1], "rb") #sys.argv[1] gets mp3 file name ex) test1.mp3 saver = "" for value in f: for i in value: hexval = hex(ord(i))[2:] if (ord(i) == 0): saver += "00" #to match with hex form else: saver += hexval header = "ffd8" tail = "ffd9" this part of code is to get mp3 as

FFMPEG: create movie from timestamped images

扶醉桌前 提交于 2020-01-23 12:42:53
问题 Im trying to make a small movie file from a folder with webcam images. They are named like this: 00-00-38.jpg 00-05-37.jpg 00-10-37.jpg 00-15-37.jpg H-M-S.jpg format Although i tried patterntype glob and simpler commands i cannot get it to work. This is what i tried: ffmpeg -r 1 -pattern_type glob -i '*.jpg' -scale=720:-1 -c:v libx264 out.mp4 (got only one image) ffmpeg -r 25 -i *.jpg -vf "scale=720:-1" output.mp4 (same size as a jpg file but no video) Console output: ffmpeg -framerate 1

How to make circle thumbnail with GraphicsMagick?

本小妞迷上赌 提交于 2020-01-23 03:39:11
问题 While exploring how to make circular crop with GraphicsMagick i came to that code: gm convert -thumbnail 200x200^ -extent 200x200 kira.jpg kira_new.jpg && gm convert -size 200x200 xc:none -fill white -draw "circle 100,100 110,0" tmp.png && gm composite -compose CopyOpacity tmp.png kira_new.jpg out.png Here's what it does: Creates 200x200 temp file named kira_new.jpg Creates transparent tmp.png with white circle in the middle Composition on tmp.png and kira_new.jpg So the question is: is there

From the results of UIImagePickerControlleHow, how do I get JPEG with metadata included in it?

我的未来我决定 提交于 2020-01-22 06:00:26
问题 On iOS 4.2 when I use UIImagePickerController to let the user select a image from the photo library these are the dictionary keys that are returned to me: 2011-03-02 13:15:59.518 xxx[15098:307] didFinishPickingMediaWithInfo: info dictionary: { UIImagePickerControllerMediaType = "public.image"; UIImagePickerControllerOriginalImage = "<UIImage: 0x3405d0>"; UIImagePickerControllerReferenceURL = "assets-library://asset/asset.JPG?id=1000000050&ext=JPG"; } Using one or more of these keys, how can I

Converting PNG into JPEG

元气小坏坏 提交于 2020-01-19 07:38:48
问题 I'm having problems converting a simple PNG into a JPEG format. I'm using the following code: ... File png = new File(filePath); try { SeekableStream s = new FileSeekableStream(png); PNGDecodeParam pngParams = new PNGDecodeParam(); ImageDecoder dec = ImageCodec.createImageDecoder("png", s, pngParams); RenderedImage pngImage = dec.decodeAsRenderedImage(); JPEGEncodeParam jparam = new JPEGEncodeParam(); jparam.setQuality(0.50f); // e.g. 0.25f File jpeg = new File("jpeg.jpeg"); FileOutputStream

Converting PNG into JPEG

耗尽温柔 提交于 2020-01-19 07:36:29
问题 I'm having problems converting a simple PNG into a JPEG format. I'm using the following code: ... File png = new File(filePath); try { SeekableStream s = new FileSeekableStream(png); PNGDecodeParam pngParams = new PNGDecodeParam(); ImageDecoder dec = ImageCodec.createImageDecoder("png", s, pngParams); RenderedImage pngImage = dec.decodeAsRenderedImage(); JPEGEncodeParam jparam = new JPEGEncodeParam(); jparam.setQuality(0.50f); // e.g. 0.25f File jpeg = new File("jpeg.jpeg"); FileOutputStream

problems with big drawable jpg image

冷暖自知 提交于 2020-01-16 19:45:07
问题 during a couple of days i've been looking here and on the Internet in many post for a solution on an issue im having loading or moving a large jpg image (located as a drawable reource by now) and I think it's time to ask myself altought there are many questions and solutions very related. I'm developing a 3D terrain simulation with OpenGL and the problem is that I'm using as terrain texture a quite large jpg image ( 2048x2048 = 1,94 MB ). Let's look at some workarround I Did: 1st: Bitmap

WIC WINCODEC_ERR_BADHEADER only for JPEG images

若如初见. 提交于 2020-01-16 19:28:26
问题 I have a simple encoding/ decoding application using Windows Imaging Component API. The issue I'm having is that when I use either the JPEGXR or BMP formats, everything works fine. However, when I use the JPEG codec - the encoder works fine and I can visually verify the generated JPEG image, but when I try to decode that stream, I get a WINCODEC_ERR_BADHEADER (0x88982f61) Here's the line that fails: hr = m_pFactory->CreateDecoderFromStream( pInputStream, NULL, WICDecodeMetadataCacheOnDemand,

Does BitmapFactory.decodeFile() file decompress the JPEG image when decoding it?

谁说胖子不能爱 提交于 2020-01-16 04:03:05
问题 JPEG is a compressed format. Does BitmapFactory.decodeFile("path to a JPEG file") decompress the JPEG image when decoding it as a Bitmap in the memory? And when I use Bitmap.compress(Bitmap.CompressFormat.JPEG, 100, byteArrayOutputStream) on the resulting bitmap from the decoded JPEG file, then the size of the compressed image is more than the size of the original image. Can anybody exactly explain this phenomenon? 回答1: Does BitmapFactory.decodeFile("path to a JPEG file") decompress the JPEG

Read byte array into buffered image WITHOUT ImageIO

送分小仙女□ 提交于 2020-01-15 12:16:08
问题 I have a code that turns a byte array into BufferedImage using ImageIO. public void readImage(byte[] imageBytes) { ByteArrayInputStream inputStream = new ByteArrayInputStream(imageBytes); BufferedImage bufferedImage = null; try { bufferedImage = ImageIO.read(inputStream); } catch (Exception e) { e.printStackTrace(); } // do something with bufferedImage } But I found that for certain jpeg images, it throws a CMMException, every time. Here's the stack trace: java.awt.color.CMMException: Cannot