I would like to force all the input image to be converted into 24bit bmp format. what parameters in gm command line I should add?
gm convert input.png -resize 1920x1080 out.bmp
I think i figured out, just let you guys know
gm convert input.png -resize 1920x1080 +matte out.bmp
Related
I am using the extract_mvs.c from ffmpeg:
https://ffmpeg.org/doxygen/2.5/extract__mvs_8c_source.html
I added opencv to imwrite the image.
cv::Mat img(frame->height,frame->width,CV_8UC1,frame->data[0]);
imwrite( "pic.jpg", img );
That works because the image in the frame is in grayscale. The camera is a color camera however, and I dont know why I am getting grayscale. If I cange the above to CV_8UC3, I get segmentation fault.
I tried to save the image with ppm_save function and I still get a black and white frame when there should be a color frame. Any ideas?
Thanks,
Chris
Just read about graphics file formats and such. JPG requires BGR24 format. The raw frame buffer format YUV420P needs to be converted to BGR24 using swscale. Then the output frames height and width needs to be manually set before calling :
cv::Mat img(out_frame->height,out_frame->width,CV_8UC3,out_frame->data[0]);
imwrite( "pic.jpg", img );
Likewise,PPM file format requires RGB24 and the raw format needs to be converted to this before saving the ppm file.
Thanks,
Chris
I just updated my Xcode to Version 8, the AppIcon I built before (for Xcode 7) are not useful anymore. And I have tried many online AppIcon generators but no one can create a full set of the AppIcon. The new version of AppIcon set is as below:
Besides, I have searched the official doc of AppIcon, the explanation and descriptions are all about the previous version. There is even no doc describing the icon size of iPhone 7. Below is a table in the Apple doc:
Anyone know the size of the whole set of AppIcon? Anyway to generate them expediently?
When you see 20pt 2x it should be 40x40, 60pt 2x 120, and 60 pt 3x 180, you just need to multiply the pt value by the x value.
To generate all the sizes I recommend using Inkscape which is excellent at resizing images.
Create your 1024x1024 icon, install imagemagick on your mac and run this script
#!/bin/bash
convert icon1024.png -resize 40x40 icon20ptx2.png
convert icon1024.png -resize 60x60 icon20ptx3.png
convert icon1024.png -resize 58x58 icon29ptx2.png
convert icon1024.png -resize 87x87 icon29ptx3.png
convert icon1024.png -resize 80x80 icon40ptx2.png
convert icon1024.png -resize 120x120 icon40ptx3.png
convert icon1024.png -resize 120x120 icon60ptx2.png
convert icon1024.png -resize 180x180 icon60ptx3.png
I downloaded ImageMagick so I could batch process folders of images at work, cropping them to size and then slicing them into 12 equal pieces. I can do each task individually, but I'd rather execute it all in one line using STDIN and STDOUT. However, even after looking through answers here and the documentation on the website, I'm not any closer to making it work.
I'm working in Windows Powershell. Here's what I've tried, working with a single image:
convert -crop '5072x3552+87+0' image.jpg jpg:- | convert -crop '1268x1184' - jpg: - | convert -crop '1268x1030+0+0' - C:\folder1\folder2\folder3\square.jpg
This gives me a series of errors:
convert.exe: no decode delegate for this image format `' #
error/constitute.c/ReadImage/508.
convert.exe: no images defined `jpg:-' #
error/convert.c/ConvertImageCommand/3253.
convert.exe: no decode delegate for this image format `' #
error/constitute.c/ReadImage/508.
convert.exe: no images defined
`C:\users\lmcane\desktop\imagem\test\leaf.jpg' #
error/convert.c/ConvertImageCommand/3253
I'm using ImageMagick 7.0.2 on Windows 7. Windows PowerShell is opened as administrator.
Additional guidance on formatting STDIN and STDOUT in imagemagick would be welcome.
Any help appreciated.
image for reference
process for single original image
I would try doing the first trim of the edges using -fuzz (to allow for small differences in the border colour) and -trim. That gets you this:
convert grid.png -fuzz 30% -trim trimmed.png
Then, I would tile to 4x3 and repage the images so they forget their positions in the original image:
convert trimmed.png -crop 4x3# +repage step2.png
Now crop off the tops, bottoms and sides and save the individual 12 frames:
convert step2.png -crop 130x100+20+20 f-%02d.png
Now you can trim the excess, using a slightly different fuzz as there seems to be less variation here than in the outer edge of the original image. And, I have also put all the commands together in one that does all the steps for all 12 images in one go:
convert grid.png -fuzz 30% -trim -crop 4x3# +repage -crop 130x100+20+20 -fuzz 5% -trim f-%02d.png
You may have to play with the fuzz factor for other images, but you should see how it works now.
I can't explain why convert throws these errors, but I was able to get it to work by using xwd as the transport format:
convert -crop '5072x3552+87+0' image.jpg xwd:- |
convert -crop '1268x1184' xwd:- xwd:- |
convert -crop '1268x1030+0+0' xwd:- C:\folder1\folder2\folder3\square.jpg
While trying to run this command:
tesseract bond111.tif bond111 batch.nochop makebox
I get the next error
Error in pixReadFromTiffStream: spp not in set {1,3}
Error in pixReadStreamTiff: pix not read
Error in pixReadTiff: pix not read
Assuming that spp not in set is the main error here, what does it mean?
At first it had trouble because the bpp was higher than 24 so I reduced it using Gimp but that did not resolve the issue.
It probably means your TIFF image has an alpha channel and therefore the underlying Leptonica library used by Tesseract doesn't support it. If you're using Imagemagick then be aware that operations such as -draw can cause alpha channels to be added. If you're using convert in your workflow and want to remove the channel again immediately, flatten the image before writing by adding -background white -flatten +matte before the output filename, e.g.:
convert input.tiff -fill white -draw 'rectangle 10,10 20,20' -background white -flatten +matte output.tiff
Tesseract (well, Leptonica) accepts PNGs these days and is less picky about them, so it might be easier to migrate your workflow to PNG anyway.
Sources: magick-users mailing list posting; tesseract-ocr mailing list posting
Thanks for your post ZakW, you pointed me to the right direction.
Anyhow i also needed to set '-depth 8'. Quality was not good enough for OCR, whatever I tried.
What worked for me is this solution:
ghostscript -o document.tiff -sDEVICE=tiffgray -r720x720 -g6120x7920 -sCompression=lzw document.pdf
tesseract document.tiff document -l deu
vim document.txt
This way I got perfect text with Umlauts in german.
Adjusting the conversion to the following line did help me.
convert -density 300 input.pdf -depth 8 -background white -alpha Off output.tiff
Note that the other answers did not work for me since they use the deprecated +matte flag instead of -alpha Off.
You can try using the command 'tiffinfo' provided by libtiff_tools to verify the TIFF format of your src image. A number of TIFF formats exist, with different values for Bits-per-pixel (bpp) and Samples-per-pixel (spp).
Error in pixReadFromTiffStream: spp not in set {1,3,4}
An 'spp' value of 2 is invalid for TIFF.
I solved the problem by saving directly to TIFF format from Gimp, instead of converting from .png to .tif using ImageMagick's 'convert'.
See also: TIFF format
i have to convert 60px X 60px images to png for my web site with imagemagick.
convert image.jpg image.png
But it's return an image with 4kbyte size.
I want get a size around 1kbyte.
How can i do?
thanks
Compression level is controlled by the -quality parameter, look here for more information. If you are only having images with less than 256 colors, use -format PNG8 to save some bytes. And try to add -type optimize.