I need to calculate the image width and height from the actual image file, so I'm reading the image with open file. so I have bunch of characters and numbers and everything that seems meaningless and they are presenting rgb information probably.
I just want to calculate the size of the image with the raw file information
I am programming in Erlang language but the code in any language will help as we are working with raw file as long as we don't use built-in libraries.
Thank you all in advance for help
I found the answer by going to details of each format,
So it works like this
JPG : you can find the width and height after the bytes "255,192,0,17,8" after that its the information for size
PNG : you can find it after "IHDR"
GIF : you can find it after "GIF89a"
there are information for more but this is the most common image types on internet
Thank you all for your time
I assume when you say 'raw' you mean you only have the pixel values.
In this case there isn't always a way to know the width and height.
Say you read 400 pixels. In this case a valid image side may be any whole factorization of 400, e.g. 1x400, 2x200, 4x100, 8x50, 20x20 etc. and transposed as well.
Not to mention the fact that many image formats include some padding for pixel rows that are not multiples of 4, 8 or 16...
The way it is coded in the image file depend on the image type, which hopefully is also coded in the image file. you can have a look at the question Getting Image size of JPEG from its binary for an example with JPEG coding.
If your data is unknown, use Octave and load the image. Then take a look at this page:
http://www.gnu.org/software/octave/doc/interpreter/Displaying-Images.html
for commands to display images. Hopefully with some manipulation it will work. This works for raw images, though there are specific decoders. Once you understand how the image is, you can write the equivalent C code.
Related
Is there a way in getting this sizes? Using command line. Thanks in advance. and can I ask something good tutorials in Dart?
I don't know a built-in feature that allows to do that except readying the content byte-wise and interpreting the values like explained for C++ in C++ How to get the Image size of a png file (in directory)
The image package seems to provide this functionality though. decodePng returns an image that has a width and height property.
The build-in function decodeImageFromList() can help you with that. Its callback contains an Image that includes the width and height.
I need to re-size image to any specific height and width value. But I'm not getting resized result. here is my code, please tell me either i'm doing something wrong or missing something.
IMOperation operationSmall = new IMOperation();
operationSmall.addImage("conf/error.png");
operationSmall.resize(300, 1000); // w*h
operationSmall.addImage("conf/errir_small.png");
Original Image size: 1280x960 px.
re-sized image size: 300x225
I tried to give different values, I'm only having issues in height.
their doc is not complete and no code example I find on internet except that using scale (it skip filtering) may solve this problem. but how to use scale in code I have not idea.
I don't read or understand java much, but at the command-line you need an exclamation mark to force ImageMagick to disregard aspect ratio and resize to exact/specific dimensions, like this:
convert -resize 300x200! image....
In the Java docs, there seems to be an option of adding a special 3rd parameter, so I guess you may need
operationSmall.resize(300,1000,'!');
or something similar... or maybe Java uses double quotes rather than the single quotes I suggested.
I'm looking for a way using the filepicker-rails gem to specify the image size. For example I would like to make it so my users cannot upload an image smaller than say 400 x 600 pixels.
Reading the docs I can only find the max file size in bytes, nothing about dimensions. Does anybody know how to accomplish this?
For now FilePicker API doesn't provide a feature of limiting files' sizes by dimensions (only by bytes as you have already mentioned).
What you could do is check the dimensions' of files and if they are lower than desired (400x600 in your case) then convert them to this minimum size using FilePicker's conversion feature.
Filepicker's new API has an option Image Dimensions where you can specify the height and width. With this local images with be upscaled or downscaled before the upload begins.
https://www.filepicker.com/documentation/file-ingestion/javascript-api/pick
Please check the specs and you-ll find out how to use the max_size :)
When I add a model to my content and run the program I get the following error
Invalid texture. face 0 is sized 522X360 , but textures using DXT
compressed formats must be multiples of four
Can anyone can help me?
Thanks in Advance
The answer is exactly what it says: the dimensions of your texture image aren't multiples of four (should ideally be powers of two) - just resize your texture images.
Set the width and height both to 512 for best results. (Use an image editor like GIMP instead of MSPaint to get a clean scale that doesn't look weird)
I'm using Tesseract OCR 3.01 in my iOS application, it shows 90% accuracy for my data when I pick an image from my phone’s library. But if I use the same image from the camera, it is showing jumbled letters. I followed this tutorial, kindly guide me if something can be done to make sure it works from camera as it works for gallery images.
Yup, There are three things to be specific, First of all, OCR works well with black and white images rather than colored, So If you could try to convert your image to B&W, it would increase accuracy.
The second thing is the size and orientation, You need to force the image to be of 640*480 or 320 size, this would increase both the speed of recognition and the accuracy as well, For orientation , there are a lot of ways to manage.
Finally, If some how you can allow the user to specify Exactly where or on which part of the image he wants to perform the OCR, this greatly increases the accuracy and time since the library does not need to check the entire image for text, rather you already specify the part to be searched for.
PS:I have been working on creating an OCR app for the past few weeks.
Almost for sure the problem is "orientation". Apple tends to create images in one bit map form - the image bits are laid out as if the camera was on its side with the volume buttons top and right. Images that you see which appear taller than wider are still laid out as above, but there is an "orientation" in the EXIF object included with the image.
I'm going to guess that tesseract does not look at the EXIF, but expects the image in a "standard" format so that text is in the position it would be for a person reading the text.
You can test my hypothesis by using camera images taken with volume button top right.
If they work, then what you will need to do is process the image yourself, and re-arrange the bits per the orientation setting. This is not all that hard to do but will require you to read up on vImage and/or bit map contexts.