Turn A JPG Into A PDF

Today’s article is an article that few folks are going to need, but those folks who do need to turn a JPG into a PDF will be happy with it. If you want to do that, this article will help you with that task.

There are times when you want to need to share an image but the people you’re working with expect a PDF. This happens if you’re sending stuff off to be printed and things like that. They only accept PDFs and all you’ve got is a JPG. 

Well, it’s easy to turn a JPG into a PDF.

JPG, or JPEG, stands for Joint Photographic Experts Group and has been a standard since 1992. Obviously, it is an image format. According to Wikipedia, JPG “… was largely responsible for the proliferation of digital images.” That sounds reasonable to me.

I’ve covered a lot of PDF stuff lately. Can you tell where I am in my notes? PDF stands for Portable Document Format and is useful when you want to print something exactly as you see it. That’s why print houses use PDFs a great deal.

I’m sure this isn’t something everyone is going to need to do. That’s fine. Not all of my articles need to apply to everyone. I’m also hoping to use this opportunity to expose you to one of the more powerful Linux applications.

ImageMagick:

The tool we’re using is a complicated tool known as ImageMagick. Once installed, you should check the man page. We’ll be limiting those options to just a couple, but manipulating images in the Linux terminal is usually done with ImageMagick. It’s a versatile application.

If you do check the man page, you’ll learn that ImageMagick is described like so:

ImageMagick – is a free software suite for the creation, modification and display of bitmap images.

That’s not a very good description, because ImageMagick does a lot more than they describe, including formats other than the BMP format. It’s a potent tool that manipulates images directly in the Linux terminal. You’ll also find that ImageMagick is a great asset when dealing with large numbers of files.

Once you’ve installed ImageMagick, you have access to the convert command. You can’t have one without the other and you only need to install ImageMagick to have access to both. If you check the man page for convert, you’ll see that it’s the correct tool for the job.

convert – convert between image formats as well as resize an image, blur, crop, despeckle, dither, draw on, flip, join, re-sample, and much more.

If you’re observant:

The convert-im6.q16 program is a member of the ImageMagick-ims6.q16(1) suite of tools.

That’s why we have to install ImageMagick to get access to the convert command. There’s a lot to ImageMagick.

So, teach you one way to turn a JPG into a PDF…

Turn A JPG Into A PDF:

As mentioned above, you need a terminal to use ImageMagick. You don’t need a terminal to install ImageMagick, you can do that in a GUI. However, I’ll share how to install ImageMagick from the terminal. You can usually open a terminal by pressing CTRL + ALT + T on your keyboard.

With your terminal open, let’s get started:

Installing ImageMagick:

ImageMagick is not only a massively capable application, it is also widely available. You should find ImageMagick available in your default repositories. If it’s not in your default repositories, you can always compile it from the source. I’ll share how to install ImageMagick in the most popular distros:

Debian/Ubuntu/etc:

Arch/Manjaro/etc:

RHEL/CentOS/etc:

You can also install ImageMagick from source:

Turning A JPG Into a PDF:

Keep your terminal open and navigate to the folder where you’ve stored the image files. Specifically, use cd to navigate to the directory that contains those images you want to turn into PDF files.

With that done, you’re only really interested in the convert flag. You won’t be invoking the imagemagick command itself. You’ll be using the convert aspect of ImageMagick.

If you want to turn a JPG into a PDF, the syntax is quite simple:

DO NOT TRY THIS YET!

An example of that command would be:

I mean, you could try it – but it’s not going to necessarily work.

If you try the above command, you’ll likely get this error:

convert-im6.q16: attempt to perform an operation not allowed by the security policy `PDF’ @ error/constitute.c/IsCoderAuthorized/421

So, we need to edit the ImageMagic’s policy.xml file. It’s a simple edit and will only take you a few minutes. I’m going to assume that you have access to Nano, but you can use any terminal text editor you want.

First, open policy.xml for editing:

Find this line:

And edit it to match this line:

Now you need to save it. To save the new policy.xml with Nano, press CTRL + X, then Y, and then ENTER. That should save the file with the same filename and extension.

That’s all you need to edit. Now you can try this command!

Now you can turn a JPG to PDF easily in the Linux terminal with the convert command as provided by ImageMagick. Pretty complicated? I suppose so, but you only need to make that edit once and you’re good to go. 

Now that you’re done with that and are happily converting JPGs to PDFs in your spare time…

Well, it gets a little more complicated.

You might find that this command produces sideways images. If that’s the case, you’ll want to use the -auto-orient flag.

I swear, that’s the last thing you should have to tweak. In my experience, you don’t need the -auto-orient flag but it’s good to know that it exists. You might consider using it by default, just to ensure things go smoothly.

Oh, one more thing…

Let’s say you have a bunch of images in a directory and you want to turn all of those .jpg images into a .pdf en masse, you can do that! The convert command supports an asterisk (wildcard). That looks like this:

That’ll happily convert all the files ending with .jpg into a single .pdf file for you to store or share with others (such as a printing company). It’s pretty easy once you know the tricks and have edited the correct file.

BONUS:

While I only say ‘JPG’ in this article, you can also use this same command with  PNG files. The command is almost the same, you just need to specify a .png file instead of operating on a .jpg file. Like so:

That will happily perform the same operation on the .png file, just like it did with the .jpg file. The only reason it’s not mentioned previously is because it would have made the titles and headings look awkward.

So, if you need to turn a PNG into a PDF, you now know how. If you wanted to turn a JPG into a PDF, you now know how. Congratulations! You’ve learned a little about ImageMagick.

Closure:

I’ve been meaning to write this article for some time. It was just too long and I didn’t quite know how to make it simple. I finally bit the bullet and wrote it. If all goes well, this will be simple enough for anyone to follow. There are a few challenges along the way that may make this difficult for a novice, but the directions are hopefully clear enough for anyone to follow.

I know that I’ve needed to turn a JPG into a PDF. I’ve had to do so specifically for the reason mentioned above. If you ship something off to a professional printer, they may want the format to be PDF.

They do that for good reason. What you see in a PDF should be exactly what you see when you print the file. It’s a pretty handy file format and the standard is open source.

Thanks for reading! If you want to help, or if the site has helped you, you can donate, register to help, write an article, or buy inexpensive hosting to start your site. If you scroll down, you can sign up for the newsletter, vote for the article, and comment.

Take A Terminal Screenshot In Terminator

This article is going to apply to those who use the Terminator terminal emulator and want to take a terminal screenshot in Terminator. That means it applies to maybe three of you. You’re welcome.

There are a zillion and three terminal emulators.

Yes, they’re terminal emulators. They, in some form or another, mimic the look and behavior of terminals. Terminals were used on old consoles and were how you interacted with things like mainframes. 

Now, you still have terminals available. If you press CTRL + ALT F3 to F6 you should see something called TTY. That stands for Teletypewriter and is from ages past. However, some pedantic people might still call it a terminal emulator or call it a virtual terminal. The latter might be closer to correct.

By the way, if you press CTRL + ALT + F7 it should/might bring you back to your desktop from TTY. If that doesn’t work, hold the LEFT ALT and press the RIGHT ARROW until you cycle back to the desktop.

I don’t want you getting lost and unable to get back to the desktop, after all.

I’ve mentioned Terminator before:

It’s Time To Introduce You To The Terminator!

This is one of my favorite terminal emulators! I use it all the time. Because I have it with a weird theme, I don’t often use it for screenshots. I should because you can take screenshots with a built-in plugin! It’s remarkably simple.

Did I mention that Terminator supports plugins? If I didn’t, well, it does!

If you want, this is a far from complete list of Terminator Plugins.

If you search online, you will find more Terminator plugins that you can use to make your terminal-based computing even easier. What you pick is up to you but one of my favorites is one that you don’t even have to work for. It’s something that should be available by default in all Terminator installs. If it’s not available, your distro chose to package Terminator without plugins. 

Terminator:

The name is as awesome as it implies and it will likely be available in any distro you choose to run as your daily driver. If you check the man page, you’ll see this:

Terminator – Multiple GNOME terminals in one window

That’s just the start of it. Also, while it’s ‘for’ GNOME doesn’t mean that it doesn’t work just fine with other desktop environments. It suits them just fine and I’ve yet to find a desktop environment that doesn’t allow me to use Terminator.

It’s a multi-windowed (if you want, and I do not) terminal with a ton of options. More importantly, for the sake of this article, it also supports plugins. 

One of those plugins lets me take screenshots that look like this:

terminator screenshot
This was taken without any additional software. It’s just Terminator doing Terminator things.

So, how is this done? What is this witchcraft?

Take A Terminal Screenshot In Terminator:

Terminator is a terminal-based application. It is a terminal emulator, after all. So, it’s going to require a terminal. You can install Terminator with your GUI package manager or you can install it via the terminal. You know what we’ll be doing, so press CTRL + ALT + T, and let’s get started.

I’m going to assume that you’re not like me and that you don’t have Terminator already installed. So, pick the right command for your package manager so that you can install Terminator.

Keep in mind that these commands are from my notes. They might be old or outdated. Be sure to verify them and let me know if I made any mistakes!

Debian/Ubuntu/etc:

Fedora/etc:

RHEL/CentOS:

Arch/Manjaro/etc:

One of those commands should work for you. If you use a different package manager, you’ll likely find that Terminator is an option. It’s a pretty popular terminal. 

Now that you have Terminator installed, you can set it as the default (if you want) or you can open it from your application menu.

With Terminator now open, right-click within the terminal menu and click on the Preferences option to continue…

Now, click on Plugins and enable “TerminalShot”, which looks like this:

Enable plugins in Terminator via the prefefrences.
This should be fairly easy to explain and I have faith that my readers will understand it.

With that enabled, you just close the preferences window.

From there,  you have this as an option when you right-click on the window:

Take screenshots within Terminator.
That’s about it, now you can save the device as a .png or a .jpg file, picking your directory first.

You’ll then be faced with a screen that looks like this:

Save the screenshot from Terminator.
If this one needs me to describe it, you probably shouldn’t be following this article…

That’s pretty obvious. What might not be obvious is that it seems to work for both .png and .jpg file formats. I’ve had good luck with both and both seem to open appropriately. I seldom use these screenshots for this site, but I have and the reason I don’t is because the color just doesn’t look good with the site’s theme. Sometimes it stands out but other times it just looks murky.

Anyhow, that’s how to take a terminal screenshot in Terminator… Pretty sweet!

Closure:

You know… I don’t know how many people are going to want to take a terminal screenshot in Terminator. I forgot to take my sleepy meds and this is the middle of the night. I’ve also been sipping away at my glass of blueberry wine. It seemed like a perfectly good article.

I was watching YouTube videos and I thought about how I do this fairly often and decided that I’d turn it into an article. There were no dissenting opinions offered, so it was turned into an article. Fortunately, I use software that makes it look like I can type coherent words! (Nah, I can do that no matter what! Plus, I’m relatively sober, just tired.)

So, if you’ve ever used Terminator, look into the various plugins available. It extends the application even more and there are some useful things in there. Terminator is one of the best terminal emulators on the planet and I’d consider dying on this hill. It’s really that good.

If you don’t agree, leave a comment. I won’t change my mind, but I will publish it. You’re welcome.

Thanks for reading! If you want to help, or if the site has helped you, you can donate, register to help, write an article, or buy inexpensive hosting to start your site. If you scroll down, you can sign up for the newsletter, vote for the article, and comment.

Mastering the Linux Terminal Pipe Command

Well, if it’s not obvious by the title, it soon will be obvious that I’ve once again leaned on AI to write an article, this time about the pipe command. I decided to stick (mostly) to the title AI gave this article, but it was longer than it should be.

AI tried to title this:

“Mastering the Linux Terminal Pipe Command: A Comprehensive Guide”

Anyhow, this is one of those articles that I just can’t write. No matter what I write, it will not be adequate – even though the pipe is a simple enough concept. Much like a recent grep article, this is just one of those articles I won’t write well.

Also, I’m not sure that I should call it a command. It’s more an operator than a command, but the references I see refer to it as a command more frequently than as an operator. Perhaps the word would be ‘operand’? But, for convenience and convention’s sake, I will call it the pipe command.

No, this isn’t something you install. This is a command that you use with other commands. It’s a lot like the operators I’ve already written about. If you’re unfamiliar with the concept, read this article:

How To: Write Text To A File From The Terminal with “>” and “>>”

The short of it is that the pipe takes the output from one command and inserts it into another command. This lets you take the output from one command and parse it with another command. That’s all there is to it – which is why I’m unable to write this article.

Which is why I leaned on my good buddy AI for this article…

Mastering the Linux Terminal Pipe Command:

In the world of Linux, the terminal pipe command stands as a quintessential tool, offering a powerful and flexible means to manipulate data streams. Understanding and mastering the pipe command can significantly enhance your efficiency and productivity in the Linux environment. In this comprehensive guide, we delve into the intricacies of the pipe command, exploring its functionalities, use cases, and advanced techniques.

What is the Pipe Command?

At its core, the pipe command, represented by the symbol |, allows you to redirect the output of one command as input to another command. This seamless connection between commands enables the creation of complex data processing pipelines, facilitating the manipulation and transformation of data with remarkable ease.

Basic Usage:

The basic syntax of the pipe command is straightforward:

Here, the output generated by command1 is passed as input to command2. This chaining of commands enables the execution of multiple operations in a single line, streamlining workflows and reducing the need for intermediate files.

Practical Examples:

Let’s explore some practical examples to illustrate the utility of the pipe command:

Counting Words in a File:

This command displays the number of words in the file file.txt. The cat command outputs the contents of the file, which are then piped to wc -w, which counts the words.

Searching for a Pattern:

Here, grep is used to search for the specified pattern in the file file.txt. The output, which consists of lines containing the pattern, is then piped to wc -l, which counts the number of matching lines.

Sorting Data:

This command sorts the lines in the file file.txt alphabetically and removes duplicate lines using the uniq command.

Advanced Techniques:

While the basic usage of the pipe command is invaluable, mastering advanced techniques can unlock its full potential:

Chaining Multiple Commands:

You can chain multiple commands together to create sophisticated data processing pipelines. Each command in the pipeline operates on the output of the preceding command, enabling complex transformations with minimal effort.

Combining Filters:

Filters such as grep, sed, and awk can be combined to perform intricate text-processing tasks. By leveraging the unique capabilities of each filter, you can manipulate data in a myriad of ways, ranging from pattern matching to text substitution.

Redirecting Output:

In addition to chaining commands, you can redirect the output of a pipeline to a file using the > operator. This allows you to capture the results of your data processing pipeline for future reference or analysis.

Common Pitfalls:

While the pipe command offers immense flexibility, it’s essential to be mindful of potential pitfalls:

  1. Order of Operations:

    The order in which commands are chained together matters. Ensure that you sequence commands appropriately to achieve the desired outcome. A misplaced command in the pipeline can lead to unexpected results or errors.

  2. Input Compatibility:

    Ensure that the output of one command is compatible with the input requirements of the next command in the pipeline. Mismatched data formats or incompatible options can result in errors or unintended behavior.

  3. Performance Considerations:

    Complex pipelines involving multiple commands may incur performance overhead. Be mindful of resource utilization, especially when working with large datasets or computationally intensive operations.

Addendum:

The Linux terminal pipe command is a versatile tool that empowers users to streamline data processing tasks effectively. By mastering its usage and exploring advanced techniques, you can unlock the full potential of the Linux command-line environment. Whether you’re a novice user or a seasoned Linux enthusiast, the pipe command remains an indispensable asset in your toolkit, enabling you to easily conquer complex data manipulation challenges.

Closure:

So, that was AI doing my job for me. Like grep, I tried to write an article about pipe, which was a hot mess. I can usually salvage articles and publish something of my work, but I just didn’t do well with a couple of subjects. This is one of them.

The thing is, I refer to the pipe command with some regularity. I don’t have an article about pipes, so I can’t link to that. This leaves the reader with a search engine and I’d rather they have an excuse to open an additional link. It’s not just good SEO, it’s good hospitality. I’ll never explain everything, but I can explain some things and people won’t need to leave the site to learn those things.

Also, even AI had issues with this article. I told it to write 1200 words and it came up with maybe 600 words. I applaud those who can turn the pipe command into more than a blurb with a few examples that help people grasp the concept. Seriously, hats off to them. I don’t write nearly as well as my volume of articles would imply.

I don’t think I’ll need to use AI for any near-future articles. I’m doing two of them fairly close together because they’re things I feel need to be done. They are articles that need to be written. It is information that needs to be on the site. I did separate the two AI-written articles by some time, just to give folks a break between them. I know, they’re not preferred and they surely don’t match my writing style.

Thanks for indulging me, if nothing else. Amusingly, this isn’t much of a time-saver. The way ChatGPT formats stuff is not compatible with the editor used by my instance of WordPress. I spend a lot of time just formatting things.

Speaking of time invested…

Thanks for reading! If you want to help, or if the site has helped you, you can donate, register to help, write an article, or buy inexpensive hosting to start your site. If you scroll down, you can sign up for the newsletter, vote for the article, and comment.

Let’s Learn About Grep

I’ve used the grep command many times but haven’t written an article to learn about grep. It seems like a good idea to do so so I can reference this article. That’s something that’s considered a good thing.

The thing is, I’ve tried to write this article before and it just came out terrible. That article never got published. It just wasn’t good enough. As you’ve seen the quality of some of these articles, tells you how bad that attempt went. 

You won’t need to install anything for this article. If you’re using a desktop or a server, you have grep. I’d expect to find grep in embedded systems because it’s just a useful tool. I suppose some companies might have ripped it out of their devices to save space and stop you from rooting around and messing with things.

So, I decided I’d do what I’d done before. I reached out to my buddy ChatGPT and asked them to write an article. Sure enough, ChatGPT did a fine job at it. This doesn’t save me much time. I still need to do all the formatting and that takes more time than you might expect.

So then, let’s get into the article…

About Grep:

The grep command in Linux is a powerful tool used for searching and manipulating text within files or standard input streams. It stands for “global regular expression print” and is primarily used to match patterns in text and display the lines that contain those patterns. grep is highly versatile and widely used in various scenarios, ranging from simple text searches to complex pattern matching and filtering tasks.

Basic Syntax:

The basic syntax for grep is as follows:

  • pattern: The pattern to search for. It can be a simple string or a complex regular expression.
  • file: Optional. The file(s) to search. If not specified, grep reads from standard input.
Common Options:
  • -i or --ignore-case: Ignore case distinctions.
  • -v or --invert-match: Invert the sense of matching, displaying non-matching lines.
  • -r or --recursive: Recursively search subdirectories.
  • -n or --line-number: Prefix each line of output with its line number.
  • -l or --files-with-matches: Display only the names of files containing matches.
  • -E or --extended-regexp: Interpret pattern as an extended regular expression (ERE).
  • -F or --fixed-strings: Interpret pattern as a list of fixed strings (not regular expressions).
Examples:

Basic Text Search:

This command searches for the occurrence of “keyword” in the file file.txt and displays all lines containing that keyword.

Case Insensitive Search:

This command performs a case-insensitive search for the pattern “pattern” in the file file.txt.

Invert Match:

This command displays all lines in file.txt that do not contain the word “exclude”.

Search in Multiple Files:

This command searches for the pattern in both file1.txt and file2.txt.

Recursive Search:

This command recursively searches for the pattern in all files within the specified directory and its subdirectories.

Display Line Numbers:

This command displays the line numbers along with the lines containing the pattern in file.txt.

Regular Expressions:

grep supports regular expressions, allowing for more advanced pattern matching. Regular expressions enable users to define complex search patterns, such as matching specific character sequences, ranges, or repetitions.

For example:

  • . matches any single character.
  • ^ matches the beginning of a line.
  • $ matches the end of a line.
  • [ ] specifies a character class.
  • * matches zero or more occurrences of the preceding element.
  • \ is used to escape special characters.
Additional Information:

The grep command is an essential tool for text processing and manipulation in the Linux terminal. Its versatility, combined with regular expressions, allows users to perform a wide range of tasks, including simple text searches, pattern matching, filtering, and data extraction. Whether it’s analyzing log files, searching for specific information in codebases, or performing system administration tasks, grep remains an indispensable utility for Linux users. Understanding its capabilities and various options can greatly enhance productivity and efficiency when working with text data in the terminal.

Closure:

So, there you have it. You have an AI-generated article about grep. It’s formatted quite differently than I’d normally format it, but it works. I dare say that AI did the job better than I had when I tried in the past.

People worry about AI but it’s just a tool. I am slowly learning when to make it useful to me. I’m not sure how many jobs AI is going to replace, but I can see lots of ways to use AI to make life easier. I can see ways to make AI more educational, such as in this article. It’s a nice overview, I think.

Thanks for reading! If you want to help, or if the site has helped you, you can donate, register to help, write an article, or buy inexpensive hosting to start your site. If you scroll down, you can sign up for the newsletter, vote for the article, and comment.

Linux Tips
Creative Commons License
This work is licensed under a Creative Commons Attribution 4.0 International License.