decode

How to resize an image an cut the excess area of it in Python?

折月煮酒 提交于 2019-12-11 06:53:31
问题 I have a string which contains the base64 code of an image. I need to resize this image to 591x608px, but I don't want it to be deformed if it has a different scale. I don't know if this is the best way (please, correct me if there is a better one), but I'm trying to add a rectangle of 591x608px to the image through the PIL library. I tried to do this with an image file and it worked, so I was trying to repeat the process with a base64 string instead of the name of the file. But I didn't

Swift 4 decoding nested JSON with random key [duplicate]

怎甘沉沦 提交于 2019-12-11 06:39:57
问题 This question already has answers here : Swift 4 Decodable with keys not known until decoding time (3 answers) Closed last year . Im new to Swift 4 and am trying to decode this JSON from the Wikipedia API. I am struggling to define a Struct because all of the examples/tutorials I have found are only nested 1 - 2 levels deep. Alongside this how can I decode the data when one of the keys is random? Thanks { "batchcomplete": "", "query": { "pages": { "RANDOM ID": { "pageid": 21721040, "ns": 0,

set the implicit default encoding\decoding error handling in python

南楼画角 提交于 2019-12-11 06:27:52
问题 I am working with external data that's encoded in latin1. So I've add sitecustomize.py and in it added sys.setdefaultencoding('latin_1') sure enough, now working with latin1 strings works fine. But, in case I encounter something that is not encoded in latin1: s=str(u'abc\u2013') I get UnicodeEncodeError: 'latin-1' codec can't encode character u'\u2013' in position 3: ordinal not in range(256) What I would like is that the undecodable chars would simply be ignored, i.e I would get that in the

How to decode and encode a float in Rust?

南笙酒味 提交于 2019-12-11 06:15:51
问题 I want to decode, store and encode a float in Rust. I know about num::Float::integer_decode() but I'd rather not lose any precision. That is, unless the format I encode into is smaller than the format I encode from of course. 回答1: Interpret the floating point bits as an integer and print out the value as hex: use std::mem; fn main() { let a_third: f64 = 1.0 / 3.0; let as_int: u64 = unsafe { mem::transmute(a_third) }; println!("{}", as_int); let as_string = format!("{:016x}", as_int); println!

Decode base64 to RGB image in matlab

痞子三分冷 提交于 2019-12-11 05:30:39
问题 I am working in Matlab environment for a project, and I have to decode a RGB image received in xml from the database server, which is encoded in base64 format. I was successful in converting image to base64 and post it to the database by converting it into xml. I used the base64encode/decode to encode the image to base64 and I have attached the program below. The problem is when I use the base64decode function and try to reconvert the image from base64. It simply does not work. This is my

Decode URL Unix/Bash Command Line (without sed) [duplicate]

梦想的初衷 提交于 2019-12-11 04:25:54
问题 This question already has answers here : Bash script to convert from HTML entities to characters (7 answers) Closed last year . I am scraping a website with curl and parsing out what I need. The URLs are returned with Ascii encoded characters like GET v2.12/...?fields={fieldname_of_type_Tab} HTTP/1.1 How can I convert this to UTF-8 (char) directly from the command line (ideally something I can pipe | to) so that the result is... GET v2.12/...?fields={fieldname_of_type_Tab} HTTP/1.1 EDIT:

Automatically Decode GZIP In TRESTResponse?

我怕爱的太早我们不能终老 提交于 2019-12-11 03:13:08
问题 It doesn't seem possible to assign a compressor or intercept to the TRESTClient. If I set TRESTRequest.AcceptEncoding to 'gzip, deflate' I receive a gzip encoded response from a server that supports gzip. However, in TIdHTTP I think it would automatically decode it. In TRESTResponse.Content it is still gzip encoded and I have to decode it manually with TIdCompressorZlib.DecompressGZipStream(). Is there a way for TRESTResponse to decode it automatically? 回答1: It's native if you set property

Check if device can decode video or not using Cordova

馋奶兔 提交于 2019-12-11 03:07:42
问题 I'm using VR view in my Ionic (Cordova) app. VR view's docs state that "some older devices cannot decode video larger than 1080p (1920x1080)". In my app, the user downloads the video file first, so it's not streaming the video. I have two videos: one for newer devices (in 4k), and one for the older devices (in 1080p). I want to check if the device is capable of decoding the 4k video. If not, it should download the 1080p video. How could I check if a device is capable of decoding 4k? I was

Encode/decode AMR

我怕爱的太早我们不能终老 提交于 2019-12-11 02:17:27
问题 I need to create custom classes for PCMtoAMR and AMRtoPCM conversion.(I don't have any framework which I can use for this conversion) Does anyone know of anything already done and available as open source. The language should preferably be java but it is no problem to port something from other language. Or if you don't know please give me guidance what to read in order to implement it myself. Thanks 回答1: This seems to be an implementation worth a look at: http://sourceforge.net/projects

IllegalArgumentException Base64 to image decoding android

拈花ヽ惹草 提交于 2019-12-11 01:48:52
问题 I want to decode an image from webservice which is in base64 to the bitmap and use it in my android app. This is my method: public Bitmap getCaptcha() throws IOException { List<NameValuePair> params = new ArrayList<NameValuePair>(); String json = jsonParser.getCaptcha(captchaURL, params); Log.i("", json); byte [] encodeByte=Base64.decode(json.getBytes(),Base64.DEFAULT); Bitmap bitmap=BitmapFactory.decodeByteArray(encodeByte, 0, encodeByte.length); return bitmap; } If I decode the string which