How to open an image file? I know a lot
of people, a lot of my students have
asked me that we could open a regular
file, a txt file using vi, cat, more, head,
or any other ways to open, it's easy or
even vi the file to open a text file.
Now the question that came up was how we
could open an image file using the
command line? Well, first of all, if you
are in a GUI environment, you could
simply double click on that image file
and it will open up. But if you do not
want to use the double clicking thing,
and you want to run a
command to open up a file, an image
file, then there is a way to do that. So
image file formats are standarized means
of organizing and storing digital
images. Image files are composed of
digital data in one of these formats
that can be rasterized for use on a
computer display or printer. An image
file format may store data in
uncompressed, compressed, or vector
format. This definition is straight out
of Wikipedia. I just want to quickly go
over it. What we will learn in this
lesson is how can we install a program
that will allow us to open an image file
and command syntax to open that image
file in GUI. Alright, so let's go into
our Linux machine. I have my Linux
machine right here. Now, if you have an
image you could undergo, you could just
simply double click and it will open up.
But the question right here we have is
we want to run a command to open up a
image. But please do remember, if
you are getting into your Linux machine
through SSH or through PuTTY, and then
you try this, it will not work because
images, GUIs, and stuff like that do not
work on Linux terminals. So for us to
try out how we could open it, we have to
actually first get an image into our
system. So I have my Firefox open. I
went to google.com. And I actually
[No audio]
clicked on Google, I typed Linux, I went
to images, and it gave me all bunch of
Linux related images. Let's pick any one
that you like, I will pick this penguin.
Right click on this image and click on
Save Image As, this will ask you where do
you want to save this image. So pick
Desktop because this is your Desktop
where you will be saving your image. So
scroll down and click Save. Now you
could go back up, you could close this
Firefox because our image is downloaded.
As you can see it is right here. And if
you want to open up this image in GUI,
all you do is you double click and it
will open up the image in your Linux,
perfect. Now, again going back to my
question is, now how can we open that
using command? So which directory I am in?
I'm in home/iafzal. If I go to my
Desktop, and do ls -l, I do see the
file is there which is 1200px which is
the same name as this. If I do cat on it,
[No audio]
that what will happen? Oops, it doesn't know
what that file is or how to open it.
Then what which other command that I
could run to open that image? Well for
that you have to install a program
called image. So what this document says
is basically you have to become root. So
let's go become root, and then you have
to run the command yum install ImageMagick.
That's a package name actually.
So let's clear the screen, and before we
do the yum install, let's make sure we
could get out to the internet. So to
confirm that we could get out to the
internet you could simply ping www.google.com,
and we are getting the reply back, perfect. Now you could go
ahead and do yum install ImageMagick -y.
[No audio]
So it is looking for the package that we
want want to download it is looking for
dependencies. Okay, it asked that the
package install packages size is 9.1
meg, it went pretty fast, because we have
given the option to, given the option
of y, which is -y for yes to
go ahead and install it. Now let's
confirm if that image, rpm has been
installed. rpm -qa | grep ImageM, so there you go.
ImageMagick, this is the rpm, this is the
program that allows you to open your
image file. Now you
have to run the command which is
displays base image of the file, the
file name actually. Alright, so before
we do that, let's get into our directory
where that image is located. So that is
in our /home/iafzal directory.
When you do ls -l, you will see it
has all the directories and files. But
we had downloaded that image file in
Desktop folder, then do ls -l, and
you will see our file is there. Now you
can run the command display, the file
name, and hit enter, and this will open
up your image file. That's how it works
if you wanted to use this command to
open up the image file. But anyway, I do
want to let you know in corporate world,
we do not have too much application or
it's used in a real world. We
don't really use this command or this
package. But anyway, I listen to my
students as always, and I have included
this lesson. So this way if someone
wants to find out how to open an image
file through the command line, they will know
how to do that. All right, good luck.
[No audio]