jpegoptim gives me this error: error creating temp file: mkstemps() failed
jpegoptim -o *.jpg
image1.jpg 2000x1333 24bit P JFIF [OK] 442829 --> 451511 bytes (-1.96%), skipped.
image2.jpg 1500x1124 24bit P Exif XMP IPTC ICC JFIF [OK] 582748 --> 583528 bytes (-0.13%), skipped.
image3.jpg 2000x1501 24bit P Exif XMP IPTC ICC JFIF [OK] 630262 --> 634146 bytes (-0.62%), skipped.
image4.jpg 1620x846 24bit P JFIF [OK] 316664 --> 319702 bytes (-0.96%), skipped.
image5.jpg 1280x855 24bit N Exif XMP Adobe [OK] 66306 --> 66279 bytes (0.04%), optimized.
jpegoptim: error creating temp file: mkstemps() failed
If you haven't figured out the issue yet, it's likely that you don't have write permissions to the directory the image is in.
Related
So when I try to use imread on a TIFF-file, it raises this error.
The TIFF-file in question is a TIFF I created and modified in another script. I initially created it like this: temp = np.full([max_y, max_x], np.nan). Then I looped the cells and changed the cell values. Afterwards I used cv2.imwrite to write it to a file.
However the original script where I create and modify the TIFF-file also opens it after writing the file so no clue why it opens then, and not in this new script. The only change I've made since then is copying the file.
I can also open the file in QGIS so no clue what the problem is.
EDIT: this is the picture https://drive.google.com/file/d/1CjAGegeA9RUmTtgd_8xgrRPqOLx8NdMa/view?usp=sharing
The relevant part of the code you can find here: https://codeshare.io/5oYNDo.
The error occurs in line 32.
EDIT 2: With the help of Mark I've got it transformed to a 32-bit image: https://drive.google.com/file/d/1xDyqeEzMrB-84ms9BB7YztbT-_kfJpeG/view?usp=sharing. However plt.imread still didn't work. So now I am using img_arr = np.asarray(Image.open(img)). However this results in a strange bug: the array is full of NaN's but when I hover over a picture I do get the cell value. (https://imgur.com/a/jbppYuO) Because of the array full of NaN's vmin and vmax are not working properly, that's why the whole picture is yellow. If I remove the vmin and vmax it's visualized as it should. But the array full of NaN's will result in problems further in the script so this has to be solved first.
Your image is a 64-bit floating point TIFF. You can see that with:
tiffinfo v3l1_24-34.tiff
Or with ImageMagick:
magick identify -verbose v3l1_24-34.tiff
PIL doesn't like such things, so you either need to either create it as 32-bit:
temp = np.full(..., dtype=np.float32)
or, if you need 64-bit, maybe read it with tifffile:
import tifffile
...
im = tiffffile.imread('v3l1_24-34.tiff')
If you have some pre-existing BigTIFF files you want to make into 32-bit classic TIFF files, you can try the following commands:
# Use an ImageMagick version with Q16 or higher and HDRI when you run "identify -version"
magick input.tif -define quantum:format=floating-point -depth 32 output.tif
# Or use "libvips" in the Terminal
vips im_vips2tiff input.tif output.tif
To check if a file is a BigTIFF or not, use exiftool and look for BTF like this:
exiftool bigtiff.tif
ExifTool Version Number : 11.11
File Name : bigtiff.tif
Directory : .
File Size : 1024 kB
File Modification Date/Time : 2020:03:13 13:56:05+00:00
File Access Date/Time : 2020:03:13 13:56:19+00:00
File Inode Change Date/Time : 2020:03:13 13:56:11+00:00
File Permissions : rw-r--r--
File Type : BTF <--- HERE
...
...
Or use xxd like this and look for 3rd byte being 0x2b:
xxd bigtiff.tif | more
00000000: 4949 2b00 0800 0000 1000 1000 0000 0000 II+.............
...
...
whereas a ClassicTIFF shows up as 0x2a:
xxd classic.tiff | more
00000000: 4949 2a00 0800 1000 0000 803f 0000 803f II*........?...?
I'm trying to convert some CMYK images from jpg to eps using convert image.jpg -format esp3 image.eps. The resulting file appears to invert or mangle the color information.
Sample of the original .jpg:
Sample of the converted .eps:
I've tried some variations of the command. The output of convert -colorspace RGB image.jpg -format esp3 image.eps, for example, looks significantly better (as in the image is identifiable). Predictably, however, the colors are not correct.
What can I do to correct the outcome? I'm open to other (linux terminal) programs or scripting languages to get the job done.
Potentially useful information:
$ convert --version
Version: ImageMagick 6.9.7-4 Q16 x86_64 20170114 http://www.imagemagick.org
Copyright: © 1999-2017 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Features: Cipher DPC Modules OpenMP
Delegates (built-in): bzlib djvu fftw fontconfig freetype jbig jng jpeg lcms lqr ltdl lzma openexr pangocairo png tiff wmf x xml zlib
This works fine for me on IM 6.9.10.84 Q16 Mac OSX.
sRGB lena.jpg:
Convert it to CMYK:
convert lena.jpg -colorspace CMYK x1.jpg
CMYK lena (x1.jpg):
Convert to EPS:
convert x1.jpg EPS3:x1.eps
A display of x1.eps using Mac Preview looks fine - no color inversion.
Likewise, using profiles is even better:
convert lena.jpg -profile /Users/fred/images/profiles/sRGB.icc -profile /Users/fred/images/profiles/USWebCoatedSWOP.icc x2.jpg
CMYK lena with profiles (x2.jpg)
Convert to EPS:
convert x2.jpg EPS3:x2.eps
Result looks like the jpg from which it was created -- no color inversion.
Post your input jpg and I can take a look.
Perhaps it is your version of ImageMagick or of libjpeg or of lcms?
convert image.jpg -format esp3 image.eps
Note: you have misspelled -format eps3 (you used esp3). So perhaps the default EPS does not support what you are trying to do. Also note I prefaced my output with EPS:. Try that, though probably won't matter.
I am trying to replicate http://kaldi-asr.org/doc/kaldi_for_dummies.html to get started onto an Automatic Speech Recognition solution i am trying to develop. I followed all the instructions within this Tutorial and then finally ran run.sh script. However i got the following errors in the terminal.
===== PREPARING ACOUSTIC DATA =====
./run.sh: line 22: data/train/spk2utt: No such file or directory
./run.sh: line 23: data/test/spk2utt: No such file or directory
===== FEATURES EXTRACTION =====
steps/make_mfcc.sh --nj 1 --cmd run.pl data/train exp/make_mfcc/train mfcc
make_mfcc.sh: no such file data/train/wav.scp
steps/make_mfcc.sh --nj 1 --cmd run.pl data/test exp/make_mfcc/test mfcc
make_mfcc.sh: no such file data/test/wav.scp
steps/compute_cmvn_stats.sh data/train exp/make_mfcc/train mfcc
make_cmvn.sh: no such file data/train/feats.scp
steps/compute_cmvn_stats.sh data/test exp/make_mfcc/test mfcc
make_cmvn.sh: no such file data/test/feats.scp
===== PREPARING LANGUAGE DATA =====
utils/prepare_lang.sh data/local/dict <UNK> data/local/lang data/lang
Checking data/local/dict/silence_phones.txt ...
--> reading data/local/dict/silence_phones.txt
--> text seems to be UTF-8 or ASCII, checking whitespaces
--> text contains only allowed whitespaces
--> data/local/dict/silence_phones.txt is OK
Checking data/local/dict/optional_silence.txt ...
--> reading data/local/dict/optional_silence.txt
--> text seems to be UTF-8 or ASCII, checking whitespaces
--> text contains only allowed whitespaces
--> data/local/dict/optional_silence.txt is OK
Checking data/local/dict/nonsilence_phones.txt ...
--> reading data/local/dict/nonsilence_phones.txt
--> text seems to be UTF-8 or ASCII, checking whitespaces
--> text contains only allowed whitespaces
--> data/local/dict/nonsilence_phones.txt is OK
Checking disjoint: silence_phones.txt, nonsilence_phones.txt
--> disjoint property is OK.
Checking data/local/dict/lexicon.txt
--> reading data/local/dict/lexicon.txt
--> text seems to be UTF-8 or ASCII, checking whitespaces
--> text contains only allowed whitespaces
--> data/local/dict/lexicon.txt is OK
Checking data/local/dict/extra_questions.txt ...
--> data/local/dict/extra_questions.txt is empty (this is OK)
--> SUCCESS [validating dictionary directory data/local/dict]
**Creating data/local/dict/lexiconp.txt from data/local/dict/lexicon.txt
utils/prepare_lang.sh: line 468: fstarcsort: command not found
utils/prepare_lang.sh: line 466: fstcompile: command not found
Exception ignored in: <_io.TextIOWrapper name=1 mode='w' encoding='latin-1'>
BrokenPipeError: [Errno 32] Broken pipe
===== LANGUAGE MODEL CREATION =====
===== MAKING lm.arpa =====
data/local/corpus.txt: No such file or directory
===== MAKING G.fst =====
./run.sh: line 75: arpa2fst: command not found
===== MONO TRAINING =====
steps/train_mono.sh --nj 1 --cmd run.pl data/train data/lang exp/mono
cat: data/lang/oov.int: No such file or directory
Here i am trying to understand the error thrown under the first section "Preparing Acoustic Data"
===== PREPARING ACOUSTIC DATA =====
./run.sh: line 22: data/train/spk2utt: No such file or directory
./run.sh: line 23: data/test/spk2utt: No such file or directory
I have made utt2spk file within the train and test data folders but i cannot understand why this error is coming? I debugged run.sh script and i found this line where i might be having the problem.
# Making spk2utt files
utils/utt2spk_to_spk2utt.pl data/train/utt2spk > data/train/spk2utt
utils/utt2spk_to_spk2utt.pl data/test/utt2spk > data/test/spk2utt
Can somebody help me troubleshoot this issue? I am using Linux Ubuntu xfce. I have g++,gcc and all dependent packages installed (not ATLAS).
I want to create a PDF with selectable/searchable text..
I have source.png which has gone through some pre-processing before OCR, and then I have view.jpg which is a compressed version of source.png to reduce the output PDF file
How do I define the view.jpg in the syntax?
tesseract -l eng source.png out pdf
I'm not sure whether you can specify view.jpg in the command. The out.pdf already contains some sort of a compressed source.png.
I want to convert a powerpoint presentation to multiple images. I already installed LibreOffice on my server and converting docx to pdf is no problem. pptx to pdf conversion does not work. I used following command line:
libreoffice --headless --convert-to pdf filename.pptx
Is there es way to convert pptx to pngs immediately or do I have to convert it to pdf first and then use ghostscript or something?
And what about the quality settings? Is there a way to choose the resolution of the resulting images?
Thanks in advance!
EDIT:
According to this link I was able to convert a pdf to images with the simple command line:
convert <filename>.pdf <filename>.jpg
(I guess you need LibreOffice and ImageMagick for it but not sure about it - worked on my server)
But there are still the problems with the pptx-to-pdf convert.
Thanks to googling and Sebastian Heyn's help I was able to create some high quality images with this line:
convert -density 400 my_filename.pdf -resize 2000x1500 my_filename%d.jpg
Please be patient after using it - you still can type soemthing into the unix console but it's processing. Just wait a few minutes and the jpg files will be created.
For further information about the options check out this link
P.S.: The aspect ratio of a pptx file doesn't seem to be exactly 4:3 because the resulting image size is 1950x1500
After Installing unoconv and LibreOffice you can use:
unoconv --export Quality=100 filename.pptx filename.pdf
to convert your presentation to a pdf. For further options look here.
Afterwards you can - as already said above - use:
convert -density 400 my_filename.pdf -resize 2000x1500 my_filename%d.jpg
to receive the images.
Convertion PPTX to PNG/JPG
This solution requires LibreOffice ( soffice ) and Ghostscript ( gs )
sudo apt install libreoffice ghostscript
Then two steps:
PPTX -> PDF
soffice --headless --convert-to pdf prezentacja.pptx
PDF -> PNG/JPG
gs -sDEVICE=pngalpha -o slajd-%02d.png -r96 prezentacja.pdf
-o slajd-%02d.png - output to file, %02d slajd number, two digits
-r96 - resolution:
96 -> 1280x720
144 -> 1920x1080
Not sure about libreoffice, but afaik its the only program to deal with pptx files.
I found this http://ask.libreoffice.org/en/question/23851/converting-pptx-to-pdf-issue/
If you have pdfs you can use imagemagick to output any quality pictures