Bash: How to get size of image compressed with JPEG2000 - imagemagick

I encoded image with jPEG2000 standard, how to get size of image after compression.
identify inputimage.pgm
works but
identify inputimage.jpc
does not work.
error is "identify: no decode delegate for this image format `J2K' # error/constitute.c/ReadImage/501."

Error messages says identify did not find necessary library to handle JPEG2000. You can check output of identify -list format to confirm that.
Indeed, it seems that JPEG2000 support is not enable in last versions of Ubuntu. Debian fixed this issue a while ago. So I suggest:
Install another distribution (Debian for exemple)
Rebuild imagemagick package with support for JPEG2000
Under Ubuntu, you can rebuild ImageMagick with JPEG2000 support following these steps:
apt-get source imagemagick
sudo apt-get build-dep imagemagick
sudo apt-get install libopenjp2-7-dev
dpkg-buildpackage -uc -us
sudo dpkg -i *deb

You can test which image formats your ImageMagick installation is able to read/write by running:
identify -list format
And further, which files ImageMagick is able to read/write by "delegating" out to a "helper program", by running:
identify -list delegate
If you are on Linux and missing JPEG2000, you will probably need to have installed the following before running ./configure to configure ImageMagick:
pkg-config
libopenjpeg
libopenjp2-7-dev
On a Mac under macOS at least, that means you need to have done:
brew install openjpeg
brew install imagemagick --with-openjpeg # Use "reinstall" if already installed

If ImageMagick does not the trick, you can try using exiftool:
exiftool -FileSize inputimage.jpc

Related

Error: yq#3 has been disabled because it is not maintained upstream! How to install a disabled brew Formulae?

I'm trying to install yq#3 on my Mac running brew install yq#3 and I get the error:
Error: yq#3 has been disabled because it is not maintained upstream!
I see that it's there on their website at https://formulae.brew.sh/formula/yq#3#default but it doesn't seem to be supported anymore.
I still need to install it since our projects at work are using this specific version.
The only way that I'm thinking about is downloading the source code, building it myself, and adding it to the path but I'm thinking that there might be a simpler solution.
Any suggestion?
Thanks!
From yq github, you can install a binary by running:
wget https://github.com/mikefarah/yq/releases/download/3.4.1/yq_darwin_amd64 -O /usr/local/bin/yq &&\
chmod +x /usr/local/bin/yq
3.4.1 is the latest 3 version, darwin_amd64 is the Mac package (don't worry about having an Intel machine and installing the package that says AMD, the name comes from something about AMD invented the 64-bit instruction set).

How can I install opencv with option --with-nonfree using brew

I installed opencv using brew on Mac. I need some option like nonfree, the command as follows:
brew install opencv --with-nonfree
But, this does't work. It just show:
Warning: opencv: this formula has no --with-nonfree option so it will be ignored!
Must I compile and install opencv from source code?
Homebrew already builds OpenCV with -DOPENCV_ENABLE_NONFREE=ON for you, so you don’t need to specify it:
brew install opencv
Use brew options opencv to get its options. Here it doesn’t output anything because Homebrew doesn’t support any option for that formula.

how do i download and install imagemagick for os x el capitan?

so i went here: https://www.imagemagick.org/script/install-source.php
and download ImageMagick.tar.gz
tried to unpack the distribution with this command:
tar xvzf ImageMagick.tar.gz
and got this error:
~ $ tar xvzf ImageMagick.tar.gz
tar: Error opening archive: Failed to open 'ImageMagick.tar.gz'
can anybody please help me get through this
Do yourself a favour if you want to install non-Apple packages and install a package manager such as homebrew which is a matter of copying and pasting a single line from the homebrew website.
Then you can find any packages you want with:
brew search imagemagick
and install them and build them with
brew install imagemagick
However, before you do that... check if you want any specific features, such as HDR or EXR support, by running:
brew options imagemagick
Sample Options
--with-fftw
Compile with FFTW support
--with-fontconfig
Build with fontconfig support
--with-ghostscript
Build with ghostscript support
--with-hdri
Compile with HDRI support
--with-liblqr
Build with liblqr support
--with-librsvg
Build with librsvg support
--with-libwmf
Build with libwmf support
--with-little-cms
Build with little-cms support
--with-little-cms2
Build with little-cms2 support
--with-opencl
Compile with OpenCL support
--with-openexr
Build with openexr support
--with-openjpeg
Build with openjpeg support
--with-openmp
Compile with OpenMP support
--with-pango
Build with pango support
--with-perl
Compile with PerlMagick
--with-quantum-depth-16
Compile with a quantum depth of 16 bit
--with-quantum-depth-32
Compile with a quantum depth of 32 bit
--with-quantum-depth-8
Compile with a quantum depth of 8 bit
--with-webp
Build with webp support
--with-x11
Build with x11 support
--with-zero-configuration
Disables depending on XML configuration files
--without-freetype
Build without freetype support
--without-jpeg
Build without jpeg support
--without-libpng
Build without libpng support
--without-libtiff
Build without libtiff support
--without-magick-plus-plus
disable build/install of Magick++
--without-modules
Disable support for dynamically loadable modules
--without-threads
Disable threads support
--HEAD
Install HEAD version
Then you can install them with a command such as:
brew install imagemagick --with-openexr --with-hdri
Later you can remove them with
brew rm imagemagick
and update all installed packages with
brew update && brew upgrade

ffprobe or avprobe not found. Please install one

I want to add tags to mp3 converted by youtube-dl & ffmpeg:
youtube-dl -o
'/Output/qpgTC9MDx1o.mp3' qpgTC9MDx1o -f bestaudio --extract-audio --metadata-from-title "%(artist)s -
%(title)s" 2>&1
I have this error in the output result:
[youtube] qpgTC9MDx1o: Downloading webpage [youtube] qpgTC9MDx1o:
Extracting video information [youtube] qpgTC9MDx1o: Downloading js
player en_US-vfluGO3jj [youtube] qpgTC9MDx1o: Downloading DASH
manifest [download]
/var/www/vhosts/mp3-y.com/httpdocs/Mp3_Output/quick-mp3.com-JALAL-EL-HAMDAOUI-2007-ARRASSIATES-VOL2-F1P-9CDoxlQ.mp3
has already been downloaded [download] 100% of 13.43MiB WARNING:
qpgTC9MDx1o: writing DASH m4a. Only some players support this
container. Install ffmpeg or avconv to fix this automatically.
[fromtitle] parsed artist: Maroon 5 [fromtitle] parsed title: Animals
ERROR: ffprobe or avprobe not found. Please install one.
Make sure you have the latest version for youtube-dl:
sudo youtube-dl -U
After that you can solve this problem by installing the missing ffmpeg.
Ubuntu and debian:
sudo apt-get install ffmpeg
macOS:
brew install ffmpeg
Windows:
choco install ffmpeg
brew install ffmpeg will install what you need and all the dependencies if you are on a Mac.
I know the user asked this for Linux, but I had this issue in Windows (10 64bits) and found little information, so this is how I solved it:
Download LIBAV, I used libav-11.3-win64.7z. Just copy "avprobe.exe" and all DLLs from "/win64/usr/bin" to where "youtube-dl.exe" is.
In case LIBAV does not help, try with FFMPEG, copying the contents of the "bin" folder to where "youtube-dl.exe" is. That did not help me, but others said it did, so it may worth a try.
Hope this helps someone having the issue in Windows.
On Windows, you can easily install ffmpeg via chocolatey
choco install ffmpeg
There is some confusion when using pip install in Windows. The instructions talk about a specific folder which has youtube-dl.exe. There is no such folder if you use pip install.
The solution is to:
Download one of the builds from https://ffmpeg.zeranoe.com/
Extract the zip contents
Place the contents of the bin folder (there are three exe files) in any folder which is a path in Windows. I personally use Ananconda, so I placed them in /Anaconda/Scripts, but you could place it in any folder and add that folder to the path.
Compiling the last answers into one:
If you're on Windows, use chocolatey:
choco install ffmpeg
If you are on Mac, use Brew:
brew install ffmpeg
If you are on a Debian Linux distribution, use apt:
sudo apt-get install ffmpeg
And make sure Youtube-dl is updated:
youtube-dl -U
What worked for me (youtube-dl version 2018.03.03, ffprobe 0.5, no avprobe, 3.4.1-tessus, in Hi-Sierra/iMac) was:
brew install libav
(thanks to marciovsena's post on GitHub).
I saw elsewhere that libav might be deprecated in the future, but I'll worry about it when we get there.
You can install them by
sudo apt-get install -y libav-tools
Update your version of youtube-dl to the lastest as older version might not support.
pip install --upgrade youtube_dl
Install 'ffmpeg' and 'ffprobe' module
pip install ffmpeg
pip install ffprobe
If you face the same issue, then download ffmpeg builds and put all the .exe files to Script folder($path: "Python\Python38-32\Scripts") (Windows OS only)
This is so simple if on windows...
In the folder where you have youtube-dl.exe
goto https://www.gyan.dev/ffmpeg/builds/
download the ffmpeg-git-full.7z file
the download link is https://www.gyan.dev/ffmpeg/builds/ffmpeg-git-full.7z
Open that zip file and move the ffmpeg.exe file to the same folder where youtube-dl.exe is
Example "blahblah.7z / whatevertherootfolderis / bin / ffmpeg.exe"
youtube-dl.exe -x --audio-format mp3 -o %(title)s.%(ext)s https://www.youtube.com/watch?v=wyPKRcBTsFQ
On a Mac, install ffmpeg by downloading it from:
https://ffmpeg.org/download.html
Under "Get packages & executable files/Static Builds for macOS 64-bit".
I downloaded ffmpeg and ffprobe.
After download, I extracted the binaries ffmpeg and ffprobe, copied them to my path and set permissions:
cp ffmpeg /usr/local/bin/
cp ffprobe /usr/local/bin/
chmod 755 /usr/local/bin/ff*
With brew install ffmpeg on macOS 10.13 I got the following Error: ffmpeg: no bottle available! and I was also not able to build ffmpeg on my machine.
on MAC i tried to run brew install ffmpeg but it didn't work and got many errors, so i did this and it worked:
1- make sure you have the latest version of youtube-dl
pip install --upgrade youtube_dl
2- go to https://evermeet.cx/ffmpeg/ and download ffmpeg and ffprobe
3- run which youtube-dl on Terminal to get the path, where youtube-dl is installed.
you should get something like this : /Library/Frameworks/Python.framework/Versions/3.9/bin/
4- copy the 2 file you downloaded ffmpeg and ffprobe to the bin folder of your path from step 3.
that's it. you shouldn't get this error again.
On WINDOWS
You can just install it by using winget. If you have Windows 11 or modern versions of Windows 10 winget comes preinstalled. so just use the below command.
winget install ffmpeg
Posting what i found recently, just so that it might be of help.
Once you have installed ffmpeg as stated by various answers here , use the below option to point to the location of ffmpeg .
in my case i've installed ffmpg in (on Windows PC) E:\ffmpeg\bin
Use underscore rather than hyphen, while invoking youtube-dl from Python, and use --ffmpeg-location if calling from command line
eg
ydl_opts = {
'ffmpeg_location' : 'E:\\ffmpeg\\bin\\ffmpeg.exe',
}
update your version of youtube-dl to the lastest as older version might not support palylists.
sudo youtube-dl -U if u installed via .deb
sudo pip install --upgrade youtube_dl via pip
use this to download the playlist as an MP3 file
youtube-dl --extract-audio --audio-format mp3 #url_to_playlist
This is an old question. But if you're using a virtualenv with python, place the contents of the downloaded libav bin folder in the Scriptsfolder of your virtualenv.

ImageMagick - PECL issue - Cannot locate header file MagickWand.h

We are getting this error while installing ImageMagick PECL:
checking ImageMagick MagickWand API configuration program... found in
/usr/local/bin/MagickWand-config checking if ImageMagick version is at
least 6.2.4... found version 6.8.6 Q16 checking for MagickWand.h
header file... configure: error: Cannot locate header file
MagickWand.h ERROR: `/root/tmp/pear/imagick/configure --with-imagick'
failed extension imagick.so installed in /usr/local/lib/php.ini
/usr/local/bin/php does not have a php.ini Tidying
/usr/local/cpanel/3rdparty/php/53/etc/php.ini... No changes
Any idea how to fix this ?
This thread is old, but I solved this issue today on a Centos 7 by installing ImageMagick-devel package:
yum install ImageMagick-devel
Hope this helps.
Steps:
apt-get install libmagickwand-dev
/opt/lampp/bin/pecl install imagick
gedit /opt/lampp/etc/php.ini
add "extension=imagick.so" to php.ini
Probably its looking for the file MagickWand.h and unable to see that file in the defined location. Try these steps
wget http://pecl.php.net/get/imagick-3.1.0RC2.tgz
tar zxf imagick-3.1.0RC2.tgz
Edit the file imagick-3.1.0RC2/config.m4 line number 55.
Make changes like this, from
if test -r $WAND_DIR/include/ImageMagick/wand/MagickWand.h;
to
if test -r $WAND_DIR/include/ImageMagick-6/wand/MagickWand.h;
Note this difference made in the imagick version number. After that try the conventional installation procedures
cd imagick-3.1.0RC2
phpize
./configure
make
make install
Perhaps this http://thomas.bindzus.me/2013/08/11/building-pecl-imagick-for-php-5-5-1-on-centos-6-4/ can be of some help to others.
The solution described by Leo Prince almost worked for me, just had to set PKG_CONFIG_PATH, and perhaps that's just my server setup which isn't as perfect as it should be.
Here is what I did step-by-step (I'm running CentOS 6.4, Apache 2.4.6, and PHP 5.5.1):
wget http://pecl.php.net/get/imagick-3.1.0RC2.tgz
tar zxf imagick-3.1.0RC2.tgz
cd imagick-3.1.0RC
phpize
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
./configure –with-imagick
make
make install
echo extension=imagick.so > /etc/php.d/imagick.ini
service httpd restart
php -m | grep imagick
First run following commands
1. "WHM Home » Software » Rebuild RPM Database"
2. yum install ImageMagick ImageMagick-devel
3. yum install pcre-devel
Then go to
Go to WHM -> Software -> Module Installers -> PHP Pecl (manage). On the
box below “Install a PHP Pecl” enter “imagick” and click “Install Now”
button – that’s all. Restart Apache.
Above steps worked for me.

Resources