Trending December 2023 # How To Edit Photos In Lightroom – The Complete Guide For Beginners # Suggested January 2024 # Top 18 Popular

You are reading the article How To Edit Photos In Lightroom – The Complete Guide For Beginners updated in December 2023 on the website Cattuongwedding.com. We hope that the information we have shared is helpful to you. If you find the content interesting and meaningful, please share it with your friends and continue to follow and support us for the latest updates. Suggested January 2024 How To Edit Photos In Lightroom – The Complete Guide For Beginners

How To Edit Photos In Lightroom – The Complete Guide

Learning how to edit photos in Lightroom is a big part of many photographer’s journeys. With all the things we see online, it doesn’t seem all that hard either! Just a few buttons here, a couple sliders there, and you’re photo looks more professional than ever.

However, after you’ve tried your hand at editing photos for yourself, you’ve likely come to one conclusion. Editing photos in Lightroom is a lot harder than you anticipated. Not to worry though, we’ve all started in the same position you are. All it takes to learn how to edit photos in Lightroom is an understanding of the tools available to you!

Photo editing shouldn’t feel like a chore. This guide will teach you the ins and outs of how to edit photos in Lightroom with an actionable and easy to follow method. Here you’ll discover the most important tools and the overall layout of the program. After reading this, you’ll be well on your way to editing photos more professionally in no time.

Why Should You Edit Photos In Lightroom

Lightroom is one of the most straight forward and accessible photo editing programs out there. Whether you’ve never edited a photo in your life or you have a general idea of what’s going on, Lightroom is so intuitive. There aren’t any fancy shortcuts or hidden tools that are difficult to remember. For the most part, what you see is what you get, and that’s a very admirable aspect of Adobe Lightroom.

A lot of the tools found in Lightroom can also be found in other programs. This makes editing photos in Lightroom an excellent starting ground for any beginner. As you begin to build your knowledge and confidence with Lightroom, other photo editing programs will feel more natural to you.

Learning how to edit your photos is one of the biggest factors of improving your photography. Taking the picture is only half the battle. If you really want to have your image stand out from the crowd, photo editing is a must. Lightroom is an extremely powerful tool to help you do just that. It gives you the ability to improve your photography without the challenges that come with learning other editing programs. Once you learn how to edit photos in Lightroom, you’ll quickly notice an improvement in your images!

The Importance Of Creating A Workflow When Editing

Although learning the different tools of Lightroom is a huge part, creating a workflow is crucial to speed up the editing process. A workflow is a series of steps that you follow to get from point A to B in your image. This doesn’t mean you always make the same adjustments, but it means you use the same type of adjustments for each step. For example, adjusting your exposure, color, and then creating spot adjustments would be considered a basic workflow.

Creating a workflow will help you to streamline the editing process and reduce the amount of time you stare blankly at the screen. Rather than hmming over what you should do next, you know exactly what series of steps to follow.

The way I outline this article is written with the intention of helping you build a workflow. Although I will be sharing info in individual tools in Lightroom, each section will offer the order of steps to follow in your edit. By putting to use the workflow outline shared here, you’ll have a clear path to success when photo editing in Lightroom.

How To Edit Photos In Lightroom (Like A Pro!)

To help you learn how to edit your photos in Lightroom, I’ll be breaking down all the essential tools. Each section will provide a new step in your Lightroom workflow, where I’ll break down the best tools the purpose they serve.  There is a lot to talk about here, so let’s dive in!

Step 1: Import Your Images How To Importing Photos Into Lightroom

A new window will open, asking you to locate your files. Choose the folder where your images are saved and select it.

All the images that are checked off will be imported into Lightroom. If there are certain images you don’t want to import, you can uncheck them now.

When you import your photos into Lightroom, you have a few options of how your files are managed. You can choose between Copy as DNG, Copy, Move or Add. If you’re unsure, Add is typically the best (and easiest) option.

Here’s what each of these options entails:

Copy As DNG: Copies files and moves them to a different folder. Converts all files into DNG files and imports to Lightroom. DNG files can be useful if your camera’s RAW file is not recognized or supported on a certain platform.

Copy: Copies all files from their original location and adds them to a new folder before importing to Lightroom. This is useful if you want to create a backup of your photos without doing in manually.

Move: Moves all files from their original location to a new location before importing to Lightroom. You could use this to import your files from your memory card and move them into a folder on your computer. A more streamlined way to add your photos!

Add: Add your photos from their existing location and import them into Lightroom. Make sure you have saved your files in a designated folder beforehand. You don’t want to add your files directly from your memory card. Ensure it’s from a specified folder on your computer.

Once you’re happy with the import method and your files are selected, press import to add your files into Lightroom. The import button is located on the bottom right of your Lightroom window.

Where To Access Your Files After Importing To Lightroom

After import, you will find your files in the specified folder within your Lightroom Catalog. As long as you use the same catalog, all of your imported files will appear within this window. That’s why it’s useful to label your folders with either dates or names to help you remember what’s in each of them!

After you help Lightroom relink your files, you’ll be able to access them once again without issue!

Ways To View Your Images In The Lightroom Library

With all of your images imported into Lightroom, you have two different view options in your Library. You can view all your pictures in Grid View or Loupe View.

Grid View: Shows all of your images in a tiled pattern. This is easy to see all your photos at once and quickly cycle through them. If you’re looking to find a certain section of images, this is the best view to do it.

Loupe View: Shows a single image in your Lightroom window. This is best for selecting images since you can see the photo up close. In Loupe View, you aren’t editing your image, but just getting a closer look at it in your library.

You can toggle between these two views in your Lightroom toolbar located beneath your photo. If you don’t have your toolbar visible, press T to bring it into view. The toolbar is handy to switch views and help you to select the best images from the bunch.

What Is A Catalog In Lightroom?

A Lightroom Catalog is a collection of images within Lightroom. Imagine it like a virtual photo book. The more pictures you add to your Lightroom Catalog, the bigger your photo book becomes. You can add all your images into one catalog or create multiple catalogs for different purposes. For example, you could create a catalog for all your vacation photos, a catalog for a certain client, and another catalog for your personal portfolio images. Lightroom Catalogs make it easier to separate and sort all of your photos into related groups.

How To Organize and Cull Photos In Lightroom

Chances are, you aren’t going to edit every photo you import. Some images will be throwaways, and others will be your next greatest photo. To make the editing process more streamlined, it’s crucial to sift through your photos and select the ones you want to edit. This organization process is also known as culling pictures and is an essential step in learning how to edit photos in Lightroom.

There are two primary methods to organize your photos. The first method is flagging, and the second method is starring. Either method works well for organizing your images, so it’s a truly personal choice.

Regardless of which method you use, the way you sift through the photos remains the same. Go into Loupe View and use your left and right arrow keys to move between images in your filmstrip. As you go between photos, select the ones you want to edit to speed boost your efficiency when you start editing.

You can see which photo is being looked at based on the highlight in your filmstrip. The Lightroom filmstrip shows a lineup of all of your images within the selected folder.

– The Flagging Method – The Star Method

The second method to cull your photos is using a star rating. By pressing the numbers 1 – 5 on your keyboard, you will add a star rating to the image. This can be useful to segment your selects into different rating values.

For example, I use the 1 star as a basic select, 2 stars if the photo needs retouching, 3 stars as a finished edit, 4 stars to mark revisions, and 5 stars to mark completed revisions.

As you learn how to edit photos in Lightroom, you’ll create your own culling method that best suits your needs. The star method is excellent to add different levels to the selections made in Lightroom.

Viewing Culled & Picked Images In Lightroom

After you’ve gone through all the images and have made your selects, it’s easiest to filter your filmstrip to selects only. This can be easily done by adjusting the filter option on your filmstrip.

If you used the flagging method, select flagged.

If you used the star method, select rated.

Now your images will be filtered to only show you the pictures you want to edit. This significantly helps to streamline your workflow by only showing you the photos you care about.

As tedious and boring as organizing can be, it’s a crucial part of learning how to edit photos in Lightroom. Spend the time to organize your photos now so you can significantly speed up your workflow later. Your future self will thank you after you’ve neatly organized all your images!

Step 2: Primary Image Adjustments

After you have imported and culled through the photos you want to edit, it’s time to make some basic adjustments. These primary adjustments are the first steps you should take in editing your pictures. Although each of these steps is not always necessary, they’re worth following when learning how to edit photos in Lightroom.

The first steps you should take when photo editing should be:

Cropping or Straightening 

Lens Corrections

Removing Chromatic Aberration 

Let’s break down each of these steps and how to use them in Lightroom. To access all of these adjustments, be sure to switch to your Develop Tab.

How To Crop Photos In Lightroom

Cropping is something that not every photo will need, so weigh whether or not this step is necessary. It can be a useful step to fix the composition of your image or get rid of distractions. Keep in mind that you want to avoid cropping your photo too much; otherwise, you’ll end up having a lower resolution.

To crop a photo, simply select the crop tool at the top of your settings window.

How To Straighten Photos In Lightroom

If your camera wasn’t level, horizon lines can look skewed and make your image look less professional. To straighten out your photo or fix slanted horizon lines, you can use the Straightening Tool in Lightroom.

In some cases, you don’t have a clear horizon to align to, so you’ll have to use your best judgment. In these situations, you can use the angle slider to straighten out your image. Simply move the slider left or right to adjust the orientation of your frame.

How To Add Lens Corrections And Remove Chromatic Abberation In Lightroom – Lens Corrections

Lens corrections, also known as profile corrections, help to counter any distortion caused by your lens. On wide-angle lenses, you may have a bubbled look near the edges of your frame. By using lens corrections, you can help to mitigate the effects of this to create a more ‘true to your eye’ image.

Within your adjustments bar, scroll down until you see a tab reading ‘Lens Corrections’. From here simply check the box reading ‘Enable Profile Corrections’ to fix any distortion and vignetting.

More often than not, Lightroom will automatically select the required camera info based on the image metadata. If this doesn’t happen, you’ll just need to manually choose your camera and lens within the profile tabs.

– Removing Chromatic Aberration

Chromatic aberration is something that can occur around the edges of things in your image. It appears as a colored fringe caused when a certain color wave isn’t focused correctly to the same focal plane. This can happen with any camera so it’s nothing to worry about, but you will want to get rid of it!

To remove chromatic aberration in Lightroom, all you need to do it check the ‘Remove Chromatic Aberration’ box.

This often will get the job done, but you can make manual adjustments if needed. If you find there is still significant color fringing in your photo, adjust the sliders under the manual tab to better target a specific color range of chromatic aberration.

Step 3: Editing Your Photos In Lightroom

Now for the exciting stuff! The hardest part of learning how to edit photos in Lightroom is to know which tools to use first. To help you build a workflow, here are the series of steps you should follow when editing an image:

Exposure Adjustments

Color Adjustments

Spot Adjustments

There are a ton of different tools that you can use in each phase of your edit. It can be hard to choose which tool is best for different situations, so it’s essential to learn how they all work.

In this section, I’ll share the uses of each tool and how they affect your photo editing in Lightroom. This way, you’ll have the know-how to find the right tool for any adjustment!

– The Basics Panel

The Basics Panel is home to all your base exposure and color temperature adjustments. These sliders are simple to use and will make the biggest impact on the exposure of your image. Here’s a list of each tool in this panel and their uses when editing a photo in Lightroom.

1. White Balance And Tint: White balance and tint are the single best way to correct any colors in your images. You may notice your unedited photo appears too purple or blue, creating an unflattering look to the picture. These sliders will correct any imbalance of color and help make your image look more true to real life.

Learn more about the importance of white balance in photography.

2. Exposure Slider: The exposure controls the overall brightness or darkness of a photo. Use this slider to adjust your image brightness globally.

3. Contrast Slider: Contrast affects the levels of your whites and blacks. As you increase your contrast, you’ll make your whites more white and your blacks more black. This contrast slider adds a global contrast boost to your image

4. Highlights & Shadows Sliders: These two sliders will affect the brightness of your highlights or shadows. The highlights are the brightest parts of your photo, while the shadows are the darkest. Adjusting these sliders is an easy way to level out your exposure and bring back details in your image.

5. Whites & Blacks: Similar to the highlight and shadow sliders, these two sliders will affect the light and dark areas of your photo. However, rather than affecting the brightest and darkest areas, these sliders affect the exposures closer to middle grey. In short, the whites and blacks sliders help to adjust the middle exposure values of your photo. The places that aren’t crazy dark or crazy bright, but somewhere in between.

6. Texture Slider: This slider adds more contrast to any edges in your photo. This is a great tool to make things pop and look a bit sharper. However, be careful not to overdo it, or you could risk creating an unrealistic looking photo!

7. Clarity Slider: This slider will add more luminance to certain colors and give an enhanced contrast feel. This can add more drama to your photos and is a great adjustment to use on clouds! Just like the texture slider, be conservative with this tool.

8. Vibrance: The vibrance slider will adjust the strength of your colors. If you want the colors in your photo to look deeper and richer, the vibrance tool will make it happen.

9: Saturation: Similar to the vibrance slider, the saturation slider also boost the intensity of your colors. Instead of boosting all the colors in your photo, the saturation seems to enhance the richness of the brightest colors.

– The Tone Curve

The Tone Curve adjustment is one of the most versatile tools in Lightroom. It can add both exposure and color adjustments making it useful in a variety of situations.

The Tone Curve is broken up into four main columns. Going from left to right they represent the shadows, darks, whites, and highlights of your photo. Depending on which section of the curve you adjust, you’ll target different exposure values in the image.

The Region Curve breaks down each quadrant of the tone curve into four sliders. This makes it easy to adjust your curve without any anchor points. This is more streamlined and much more beginner-friendly. This curve is excellent if you only want to make exposure adjustments. It’s not possible to edit color with this version of the Tone Curve. The Region Curve also limits the amount you can adjust the exposure values to prevent clipping.

Editing Colour With The Tone Curve

Learn More About How To Master The Tone Curve In Lightroom.

– HSL Adjustments

The HSL Adjustment in Lightroom is all about changing the look of your colors. HSL stands for Hue Saturation and Luminance. Together, these three options can completely transform the look of your photos.

The HSL Adjustment splits up all the color values in your image into 8 different channels. Depending on your image, certain channels or adjustment tabs will have more effectiveness in your photo than others. It’s useful to go through each tab individually to see the effects they offer!

Hue: Changing the color hue will change how a particular range of colors appear. For example, you could alter the hue of yellow to make it appear more orange. You could change the hue of blue to make it more purple. The hue sliders are a super useful tool to apply creative looks to your photo!

Saturation: Similar to the saturation slider found within the Basics Panel, the saturation sliders of HSL alter the richness of colors. Since each color is broken up into a certain range, you can easily target different values to saturate or desaturate color. Another powerful and simple way to enhance your photo in Lightroom.

Luminance: Luminance is the lightness of a color. As you increase the luminance, you will essentially alter the exposure of a color. The Luminance Sliders are an easy way to lighten or darken sections of your photo based on color!

– Split Toning

As you learn how to edit photos in Lightroom, Split Toning is excellent for easily adding stylized color effects. Rather than adjusting the colors that are already in your photo, you can add color to your image. This adjustment lets you add a specific color to both your highlights and shadows for total color control!

Split Toning in Lightroom is broken down into highlights and shadows. Each exposure value has its own sliders to adjust the hue or saturation.

The Hue Slider will pick the color tone to be applied to your photo.

The Saturation Slider will dictate how visible that color tone is in the photo.

In between the highlight and shadow adjustments is the Balance Slider. This slider allows you to choose the dominance one color hue has over the other. For example, you could set the balance to favor the shadows so that hue becomes more dominant. It can take a bit of playing around, but the Balance Slider can really refine the split toning adjustments!

– The Detail Panel

The Detail Panel in Lightroom is home to all your sharpening and noise reduction needs. It might look a bit overwhelming at first, but there are only two main sliders you really should worry about.

The two most important sliders in the Detail Panel are the Sharpening and Luminance sliders.

Sharpening Amount Slider: This slider will set how much sharpness is applied to your photo. Sharpness is an essential part of your photo edit in Lightroom since it makes your image look more clear. It boosts the amount of contrast and grain around edges in your frame to create more perceived clearness. Be sparing with this adjustment so you don’t add too much grain!

Luminance Noise Reduction: This slider will smooth out any noise present in your photo. It works by leveling out any areas of distortion in your image. This can work great to get rid of noise, but it also can make your image look fake and plastic. I tend to never go higher than 10 on this slider.

– Calibration

The Calibration Tab is a lesser-known and slightly more mysterious tool to many. When people are learning how to edit photos in Lightroom, they tend to skip over this tool altogether. However, I think there is a ton of value the calibration adjustments can add to the colors of your photos.

Unlike other color adjustments we have talked about so far, the Calibration Tool adjusts the hue and saturation of your actual color channels. To put things simply, your photo is broken down into three main colors. Those colors being Red, Green, and Blue, otherwise known as RGB.

Together, these colors make up all other colors in your image. So when you adjust the entire channel, you end up with some really neat effects. With very subtle adjustments to the Calibration Sliders, you can totally transform the mood of your pictures.

These sliders are a really great tool to experiment with after you’ve made the bulk of your adjustments. It can really act as the cherry on top of your edit in Lightroom!

Step 4: Spot Adjustments

All the editing tools we have talked about so far adjust your image globally. This is great for an overall look, but what about when you want to target a certain area. Luckily there are a few easy to use spot adjustments in Lightroom that will do just the trick!

All of these adjustment tools can be access at the top of your settings bar. Once you select an adjustment, a new Basic Panel will appear. The adjustments you make in this panel will only affect the areas you have selected.

– Adjustment Brush

When you select an area with the Adjustment Brush, it will be shown as a little circle over your image. When you hover over this circle, a red highlight will appear to show where your adjustments are affecting.

The Adjustment Brush in Lightroom is automatically set to add to your selection. What about if you want to get rid of your adjustment area?

To erase part of your selection, hold the ALT or OPTION key and paint over your image. This will get refine where your adjustments are targeting.

Inside the brush you’ll find two circles. The gap between the outer and inner circle represents the brush feather. In basic terms, the feather will soften the edge of your brush. A larger feather will give a more natural fade around the edge of your selected area.

You can locate the brush panel beneath all your settings. Here you can change the size, feather, flow, and density of your adjustment brush in Lightroom.

– Gradient Filter

The Gradient Filter creates localized adjustments that transition from 100% to 0% visibility. This is great to make subtle adjustments to the sky or edges of your photo.

You can alter the feather of the gradient by moving the two lines further apart. The further away the lines of your gradient filter are, the softer and less noticeable the transition becomes.

This tool is extremely straightforward and doesn’t have any hidden tricks or secrets to it. What you see is what you get when learning how to use the Gradient Tool in Lightroom.

– Radial Filter

The Radial Filter is similar to the Gradient Filter, except it creates a circular gradient. This is great to make adjustments in a specific spot in your photo. For example, you could put a radial gradient around your subject to add localized brightness. You could also use this filter to darken the edges of your frame for a more moody look.

You can make adjustments both inside and outside with the radial filter. You can toggle between the two by checking the Invert box at the bottom of your settings panel. This will switch whether your adjustments are applied to the inside or outside of your radial gradient.

For even further customizable to the Radial Filter, you can adjust the feather. The feather slider will decide how soft the edges of your gradient will be. You can experiment with this, but I find 50 to work well in most scenarios!

– The Spot Removal Brush

There will often be things in your images that you’ll need to remove. Whether that’s a sensor spot, a piece of garbage on the sidewalk, or something on your subject’s clothes. Whenever you’re editing a photo in Lightroom and need to get rid of something, the Spot Removal Brush will be your hero!

The Spot Removal Brush works a lot like the Adjustment Brush in Lightroom. The difference being, the Spot Removal Brush removes anything you paint over.

When you paint over something with this tool, it tries to find another similar area of your photo to replace it with. It’s not actually getting rid of something, but just hiding it behind another sampled part of your image.

There are 3 main adjustments you have access to with the Spot Removal Brush:

Size

Feather

Opacity

The size will alter the size of the brush you use to paint over something in your photo.

The feather will dictate how soft the edges of your replaced area look.

While the opacity chooses how visible the sampled area appears over the spot you want to remove.

When you paint over something with the Spot Removal Brush in Lightroom you’ll see a white line. This white line represents the sampled area that will be removed. From here, Lightroom automatically selects a similar part of your image to replace it with.

Sometimes the area it automatically chooses to sample from doesn’t quite work as well as you’d hope. In that case, you can manually move around the sampling area to dictate the final result.

If you’re removing something against a simple background like the sky, Lightroom will have an easy time to find a new area to sample from. However, it will struggle when you try to get rid of something with a complicated background or specific lighting.

So yes, the Spot Healing Brush Tool will remove things from your photo, but it’s not always perfect. Regardless, it’s still an incredibly useful tool to use as you learn how to edit photos in Lightroom.

Step 5: Exporting Photos From Lightroom

After you’ve finished editing your photo in Lightroom, it’s time to share it with the world! That means it’s time to export.

Luckily learning how to export images from Lightroom is a breeze. There are just a few crucial steps to keep aware of. The most important things to consider when exporting images from Lightroom are:

Metadata

File Type

Export Location

Let’s break down each of these steps individually.

– How To Edit Your Image Metadata In Lightroom

Metadata is the information behind your photo. In an image’s metadata you can find copyright information, camera settings, and even location info. Particularly when you’re sharing your photos online, it’s important to add copyright info to your image. That way you can always claim it as rightfully yours!

Below is a super in-depth tutorial about adding metadata to Lightroom images by Aaron Nace. Even if you’re a total beginner, it’s essential to stay on top of your metadata!

– Step By Step Guide To Exporting Images From Lightroom

A new dialogue box will appear with all of the export information for your image. Let’s go through each crucial export section and discover what they’re used for.

3. File Settings: If you need to change the type of file you’re exporting, you can do that in this File Settings tab. Here you can set your file type to a series of different options. If you have no idea what these file types are, just export your image to JPEG for the most versatility. Just make sure you set your quality to 100 if you want to best resolution possible with your export!

Conclusion

So that was everything you need to know about how to edit photos in Lightroom like a pro! The tips discussed in this guide will help you to edit photos more efficiently and with added confidence in Lightroom. No matter how you go about it, learning how to edit pictures takes time and practice. Don’t let yourself get discouraged and keep experimenting with new techniques!

If you enjoyed this article, be sure to share it with a friend who’s wanting to learn how to edit photos in Lightroom! By sharing this guide, you help to support my blog and the creation of more articles like this one. I appreciate you!

If you want to stay up to date with more articles like this one, be sure to subscribe to my weekly newsletter for more great tips and tutorials!

You're reading How To Edit Photos In Lightroom – The Complete Guide For Beginners

How To Use The Move Tool In Photoshop (Complete Guide)

Where To Find The Move Tool In Photoshop

Just like all other tools in Photoshop, the Move Tool can be found in the toolbar. Unless you’ve customized your workspace, the toolbar can be found on your screen’s left edge.

The Move Tool is always easy to spot since it’s positioned at the top of the toolbar, represented by the four-way arrow.

What Is The Move Tool In Photoshop

Just as the name says, the Move Tool moves things around your canvas. Whether that be layers, text, or selections, this tool has you covered. It can also be used to align layers to your canvas or an active selection.

In a nutshell, the Move Tool can be used with the following:

Entire Layers: Whether it be smart objects or a regular layer, the Move Tool can select and reposition an entire layer at once.

Selections: Any selection can be repositioned with the Move Tool, but the selected layer behind the selection will come with it.

How To Use The Move Tool In Photoshop

Let’s go over the different ways you can start using the Move Tool more effectively in your workflow.

– Moving Layers With The Move Tool

Since just about anything can be moved with this tool, how can you make that happen?

First, you need to select a layer!

Fortunately, selecting a layer is easy. There are actually two different ways you can do it with the Move Tool.

To enable auto-select, check off the ‘auto-select’ option in your top settings bar while the Move Tool is active.

– Resizing Layers With The Move Tool

Besides moving a layer from point A to B, the Move Tool in Photoshop can scale your layers.

Before you can do this, you need to make sure the ‘Show Transform Controls’ option is selected. This option is found in your settings bar while the Move Tool is active.

With the transform controls selected, any selected layer will have a box around it with eight anchor points.

With transform box Without transform box

– Aligning Layers With The Move Tool In Photoshop

It’s all great and dandy that you can move and scale layers freely with the Move Tool in Photoshop, but what about specific alignments? Luckily you can align any layer you’d like to either a selection or your entire canvas!

Aligning Layers To Your Canvas

The easiest way to align a layer is to the canvas as a whole. This means that your layer will align itself according to the width and height of your entire image.

This will bring up additional alignment options that will likely be greyed out at first.

That is until you change the ‘Align To’ option to ‘Canvas’.

Now you can pick any of the alignment options to align your layer with.

Aligning Layers To A Selection

This time change the ‘Align To’ option to ‘Selection’.

Now your alignment options will align your layer according to the shape and size of the active selection.

The Move Tool Alignment Options Explained

With the alignment options found within the Move Tool in Photoshop, there are a few odd-looking icons. At first, these icons may look pretty foreign and hard to understand. To help make aligning layers easy, let’s break down each alignment option in Photoshop.

Horizontal Alignment Options

Align Right Edges: Matches up the right edge of your layer to the right edge or your canvas or selection.

Align Horizontal Centers: Positions the middle of your layer with the horizontal center of the canvas or selection.

Align Left Edges: Lines up the left edge of your layer with the left edge of your canvas or active selection.

Vertical Alignment Options

Align Top Edges: Aligns the top edge of your layer with the top edge of your canvas or selection.

Align Vertical Centers: Places the middle of your layer with the vertical center of your canvas or selection.

Align Bottom Edges: Lines up the bottom edge of your layer with the bottom edge of the canvas of selection.

Move Tool Shortcuts & Additional Tips

Now you have a handle on how to use the Move Tool in Photoshop. Let’s take it one step further with additional tips and shortcuts to help you make the most of this tool.

1. Toggling The Move Tool

The Move Tool in Photoshop is usually only used for a quick repositioning adjustment. So wouldn’t you say it’s a bit annoying to have to select the Move Tool, then a layer, then reposition?

Luckily there’s a way to toggle the Move Tool while using any other tool in Photoshop.

Just hold the Command (Mac) or Control (PC) key to quickly bring up the Move Tool. Now you can reposition a layer and go back to your adjustments with one simple shortcut!

2. Duplicate And Move Layers

If you need to duplicate a layer and reposition it simultaneously, there’s another easy shortcut for that.

4. Nudging Layers For Subtle Adjustments

Not every repositioning adjustment needs to be that noticeable. Maybe you just need your layer a few pixels over to the left. While using a mouse, these small adjustments are extremely challenging.

That’s where nudging comes in to save the day.

With any layer selected by the Move Tool, use the arrow keys to nudge your layer in any direction. This is an easy trick to really refine a layer’s positioning.

So that’s everything you need to know about how to use the Move Tool in Photoshop. There’s a lot more to this tool than what first meets the eye. Although some may dismiss the Move Tool as only good for one job, it has a variety of great uses. Best of all, it’s very intuitive once you learn the basics and is a simple tool for any beginner to master.

– Brendan 🙂

A Beginners Guide To Multi

This article was published as a part of the Data Science Blogathon

In the era of Big Data, Python has become the most sought-after language. In this article, let us concentrate on one particular aspect of Python that makes it one of the most powerful Programming languages- Multi-Processing.

Now before we dive into the nitty-gritty of Multi-Processing, I suggest you read my previous article on Threading in Python, since it can provide a better context for the current article.

Let us say you are an elementary school student who is given the mind-numbing task of multiplying 1200 pairs of numbers as your homework. Let us say you are capable of multiplying a pair of numbers within 3 seconds. Then on a total, it takes 1200*3 = 3600 seconds, which is 1 hour to solve the entire assignment.  But you have to catch up on your favorite TV show in 20 minutes.

What would you do? An intelligent student, though dishonest, will call up three more friends who have similar capacity and divide the assignment. So you’ll get 250 multiplications tasks on your plate, which you’ll complete in 250*3 = 750 seconds, that is 15 minutes. Thus, you along with your 3 other friends, will finish the task in 15 minutes, giving you 5 minutes time to grab a snack and sit for your TV show. The task just took 15 minutes when 4 of you work together, which otherwise would have taken 1 hour.

This is the basic ideology of Multi-Processing. If you have an algorithm that can be divided into different workers(processors), then you can speed up the program. Machines nowadays come with 4,8 and 16 cores, which then can be deployed in parallel.

Multi-Processing in Data Science-

Multi-Processing has two crucial applications in Data Science.

1. Input-Output processes-

Any data-intensive pipeline has input, output processes where millions of bytes of data flow throughout the system. Generally, the data reading(input) process won’t take much time but the process of writing data to Data Warehouses takes significant time. The writing process can be made in parallel, saving a huge amount of time.

2. Training models

Though not all models can be trained in parallel, few models have inherent characteristics that allow them to get trained using parallel processing. For example, the Random Forest algorithm deploys multiple Decision trees to take a cumulative decision. These trees can be constructed in parallel. In fact, the sklearn API comes with a parameter called n_jobs, which provides an option to use multiple workers.

Multi-Processing in Python using Process class-

Now let us get our hands on the multiprocessing library in Python.

Take a look at the following code

Python Code:



The above code is simple. The function sleepy_man sleeps for a second and we call the function two times. We record the time taken for the two function calls and print the results. The output is as shown below.

Starting to sleep Done sleeping Starting to sleep Done sleeping Done in 2.0037 seconds

This is expected as we call the function twice and record the time. The flow is shown in the diagram below.

Now let us incorporate Multi-Processing into the code.

import multiprocessing import time def sleepy_man(): print('Starting to sleep') time.sleep(1) print('Done sleeping') tic = time.time() p1 = multiprocessing.Process(target= sleepy_man) p2 = multiprocessing.Process(target= sleepy_man) p1.start() p2.start() toc = time.time() print('Done in {:.4f} seconds'.format(toc-tic))

Here multiprocessing.Process(target= sleepy_man) defines a multi-process instance. We pass the required function to be executed, sleepy_man, as an argument. We trigger the two instances by p1.start().

The output is as follows-

Done in 0.0023 seconds Starting to sleep Starting to sleep Done sleeping Done sleeping

Now notice one thing. The time log print statement got executed first. This is because along with the multi-process instances triggered for the sleepy_man function, the main code of the function got executed separately in parallel. The flow diagram given below will make things clear.

In order to execute the rest of the program after the multi-process functions are executed, we need to execute the function join().

import multiprocessing import time def sleepy_man(): print('Starting to sleep') time.sleep(1) print('Done sleeping') tic = time.time() p1 = multiprocessing.Process(target= sleepy_man) p2 = multiprocessing.Process(target= sleepy_man) p1.start() p2.start() p1.join() p2.join() toc = time.time() print('Done in {:.4f} seconds'.format(toc-tic))

Now the rest of the code block will only get executed after the multiprocessing tasks are done. The output is shown below.

Starting to sleep Starting to sleep Done sleeping Done sleeping Done in 1.0090 seconds

The flow diagram is shown below.

Since the two sleep functions are executed in parallel, the function together takes around 1 second.

We can define any number of multi-processing instances. Look at the code below. It defines 10 different multi-processing instances using a for a loop.

import multiprocessing import time def sleepy_man(): print('Starting to sleep') time.sleep(1) print('Done sleeping') tic = time.time() process_list = [] for i in range(10): p = multiprocessing.Process(target= sleepy_man) p.start() process_list.append(p) for process in process_list: process.join() toc = time.time() print('Done in {:.4f} seconds'.format(toc-tic))

The output for the above code is as shown below.

Starting to sleep Starting to sleep Starting to sleep Starting to sleep Starting to sleep Starting to sleep Starting to sleep Starting to sleep Starting to sleep Starting to sleep Done sleeping Done sleeping Done sleeping Done sleeping Done sleeping Done sleeping Done sleeping Done sleeping Done sleeping Done sleeping Done in 1.0117 seconds

Here the ten function executions are processed in parallel and thus the entire program takes just one second. Now my machine doesn’t have 10 processors. When we define more processes than our machine, the multiprocessing library has a logic to schedule the jobs. So you don’t have to worry about it.

We can also pass arguments to the Process function using args.

import multiprocessing import time def sleepy_man(sec): print('Starting to sleep') time.sleep(sec) print('Done sleeping') tic = time.time() process_list = [] for i in range(10): p = multiprocessing.Process(target= sleepy_man, args = [2]) p.start() process_list.append(p) for process in process_list: process.join() toc = time.time() print('Done in {:.4f} seconds'.format(toc-tic))

The output for the above code is as shown below.

Starting to sleep Starting to sleep Starting to sleep Starting to sleep Starting to sleep Starting to sleep Starting to sleep Starting to sleep Starting to sleep Starting to sleep Done sleeping Done sleeping Done sleeping Done sleeping Done sleeping Done sleeping Done sleeping Done sleeping Done sleeping Done sleeping Done in 2.0161 seconds

Since we passed an argument, the sleepy_man function slept for 2 seconds instead of 1 second.

Multi-Processing in Python using Pool class-

In the last code snippet, we executed 10 different processes using a for a loop. Instead of that we can use the Pool method to do the same.

import multiprocessing import time def sleepy_man(sec): print('Starting to sleep for {} seconds'.format(sec)) time.sleep(sec) print('Done sleeping for {} seconds'.format(sec)) tic = time.time() pool = multiprocessing.Pool(5) pool.map(sleepy_man, range(1,11)) pool.close() toc = time.time() print('Done in {:.4f} seconds'.format(toc-tic))

multiprocessing.Pool(5) defines the number of workers. Here we define the number to be 5. pool.map() is the method that triggers the function execution. We call pool.map(sleepy_man, range(1,11)). Here, sleepy_man  is the function that will be called with the parameters for the functions executions defined by range(1,11)  (generally a list is passed). The output is as follows-

Starting to sleep for 1 seconds Starting to sleep for 2 seconds Starting to sleep for 3 seconds Starting to sleep for 4 seconds Starting to sleep for 5 seconds Done sleeping for 1 seconds Starting to sleep for 6 seconds Done sleeping for 2 seconds Starting to sleep for 7 seconds Done sleeping for 3 seconds Starting to sleep for 8 seconds Done sleeping for 4 seconds Starting to sleep for 9 seconds Done sleeping for 5 seconds Starting to sleep for 10 seconds Done sleeping for 6 seconds Done sleeping for 7 seconds Done sleeping for 8 seconds Done sleeping for 9 seconds Done sleeping for 10 seconds Done in 15.0210 seconds

Pool class is a  better way to deploy Multi-Processing because it distributes the tasks to available processors using the First In First Out schedule. It is almost similar to the map-reduce architecture- in essence, it maps the input to different processors and collects the output from all processors as a list. The processes in execution are stored in memory and other non-executing processes are stored out of memory.

Whereas in Process class, all the processes are executed in memory and scheduled execution using FIFO policy.

Comparing the time performance for calculating perfect numbers-

 

Using a regular for a loop- import time def is_perfect(n): sum_factors = 0 for i in range(1, n): if (n % i == 0): sum_factors = sum_factors + i if (sum_factors == n): print('{} is a Perfect number'.format(n)) tic = time.time() for n in range(1,100000): is_perfect(n) toc = time.time() print('Done in {:.4f} seconds'.format(toc-tic))

The output for the above program is shown below.

6 is a Perfect number 28 is a Perfect number 496 is a Perfect number 8128 is a Perfect number Done in 258.8744 seconds Using a Process class- import time import multiprocessing def is_perfect(n): sum_factors = 0 for i in range(1, n): if(n % i == 0): sum_factors = sum_factors + i if (sum_factors == n): print('{} is a Perfect number'.format(n)) tic = time.time() processes = [] for i in range(1,100000): p = multiprocessing.Process(target=is_perfect, args=(i,)) processes.append(p) p.start() for process in processes: process.join() toc = time.time() print('Done in {:.4f} seconds'.format(toc-tic))

The output for the above program is shown below.

6 is a Perfect number 28 is a Perfect number 496 is a Perfect number 8128 is a Perfect number Done in 143.5928 seconds

As you could see, we achieved a 44.4% reduction in time when we deployed Multi-Processing using Process class, instead of a regular for loop.

Using a Pool class- import time import multiprocessing def is_perfect(n): sum_factors = 0 for i in range(1, n): if(n % i == 0): sum_factors = sum_factors + i if (sum_factors == n): print('{} is a Perfect number'.format(n)) tic = time.time() pool = multiprocessing.Pool() pool.map(is_perfect, range(1,100000)) pool.close() toc = time.time() print('Done in {:.4f} seconds'.format(toc-tic))

The output for the above program is shown below.

6 is a Perfect number 28 is a Perfect number 496 is a Perfect number 8128 is a Perfect number Done in 74.2217 seconds

As you could see, compared to a regular for loop we achieved a 71.3% reduction in computation time, and compared to the Process class, we achieve a 48.4% reduction in computation time.

Thus, it is very well evident that by deploying a suitable method from the multiprocessing library, we can achieve a significant reduction in computation time.

The media shown in this article are not owned by Analytics Vidhya and is used at the Author’s discretion. 

How To Use Grids & Guides In Photoshop (Complete Guide)

Learning how to use grids and guides in Photoshop is useful to compose your project and put objects in the exact position you need them. They aren’t difficult to use once you know how to set them up and use the different settings. Let’s take an in-depth look at how to make Photoshop’s grids and guides work for you.

How To Use Photoshop Grids

A grid is an overlay you can add to your canvas that can help you compose your project. The grid only shows up while you’re working on the project – when you export, the grid will be gone. 

The grid’s main purpose is as a composition tool, helping you align objects. This can be especially useful for landscape photographers trying to straighten the horizon, or for architecture photographers working with lots of lines and angles.

On a blank canvas, it’ll look something like this.

– Adjusting Grid Sizing 

There are some instances when you might need to change the size of the space between grid lines. When you add a grid to your canvas, the size is set automatically. But occasionally the grid appears too large or small for the project you’re working on. 

For instance, the photo I uploaded below was too big for the tiny grid to be of any use.

In the Grid section, you can change the number and unit of measurement of the space between each gridline. 

Let’s take the example in the photo above and increase the spacing between the grid lines since a gridline every 2 centimeters is much too close. Let’s alter the settings so that there is a gridline every 10 centimeters.

That size fits the photo much better. Now, using the grid, I can line up elements like sections of the road, the trees, and the side of the house to create the cleanest composition.

How To Use Photoshop Guides

Guides are similar to grids in that both give you a visible set of lines to help you place objects, align elements, or otherwise compose your project. However, unlike Grids, you set the guides yourself, giving you even more control over what visual guidelines you can see on your canvas.

Now rulers will appear at the top and side of your project in the unit of measurement set in your preferences.

Now, the guide will appear in the orientation and position you set. This method is easiest for setting a guide in a certain part of your canvas automatically.

Once a guide is created, you can use the Move Tool to drag it into a new position on your canvas.

– Using Smart Guides

Manual guides take a second to set up, so if you’re looking for a quick fix, Smart Guides are a great method to quickly align elements without having to go through the steps of creating a guide yourself.

Once you’ve enabled smart guides, they’ll show up while you’re moving objects to help guide where they can go as well as show their relation to other objects. Notice how the smart guide below tells me when the pink and black rectangles are perfectly aligned. For me, the smart guides appear in pink, but we’ll cover how to change the color in a moment.

– How To Center Guides

A guide will appear in the center of your canvas in the orientation you chose. If you’d like both vertical and horizontal guides running through the center of your canvas, repeat the same step for the other orientation.

You’ll now see both guides centered. To make sure you don’t accidentally move these guides, follow the steps in the next section to lock them in place.

– How To Lock Guides How To Create Custom Guide Layouts In Photoshop

If you’d like your guide to have multiple lines with specific spacing, you can quickly create a custom guide layout. This is much faster and easier than creating and positioning each guide individually. 

In the window that appears, you can choose the settings for your new guide layout. This allows you to add as many rows and columns as you need to your guide, as well as specify the width and height for each. You can also set the size of the gutter, aka the space between the lines.

Keep in mind that there is no place to select a measurement unit, so you’ll have to type the measurement you’d like to use with the unit. For instance, the automatic number and unit size of my gutter is 1.693mm, but you could also use pixels, points, centimeters – whatever works best for your project.

You’ll notice the guides are visible on the canvas and change as you edit the settings. For instance, I set my guides to have the following settings:

These guides show up on my canvas like this:

How To Change The Color Of Your Grids & Guides

Let’s break that down more in-depth.

To change the appearance of your guides, head to the Guides section.

You can also change the type of line that appears if need be.

In the preferences window, you can adjust the color and appearance of the lines in the grid under the Grid section.

Useful Keyboard Shortcuts For Grids & Guides

While working with grids and guides, there are a few ways you can optimize your workflow and speed up the process a bit.

To quickly show the grid, use Command + ‘ on a Mac and Control + ‘ on a PC.

In order for guides to function at their best, it helps to have the rulers visible vertically and horizontally on your canvas. To quickly show both rulers, use Command + R for Mac, and Control + R for PC. The rulers will appear at the top and side of your canvas.

You can easily remove guides to get them out of the way by dragging them off the image and back onto the ruler.

How To Use Snapping

You can also disable snapping temporarily by holding down Command on a Mac or Control on a PC while you’re placing an object, but keep in mind this only works with the Move tool active.

Grids and Guides are helpful tools for a variety of different projects, from editing photos to designing graphics. They are easy to use once you’ve learned the ins and outs, and will surely help you with creating the perfect compositions for your projects.

Happy Editing!

A Comprehensive Guide To Conditional Statements In Python For Data Science Beginners

This article was published as a part of the Data Science Blogathon

Introduction

Decision-making is as important in any programming language as it is in life. Decision-making in a programming language is automated using conditional statements, in which Python evaluates the code to see if it meets the specified conditions.

The conditions are evaluated and processed as true or false. If this is found to be true, the program is run as needed. If the condition is found to be false, the statement following the If condition is executed.

Python has six conditional statements that are used in decision-making:-

1. If the statement

2. If else statement

3. Nested if statement

4. If…Elif ladder

5. Short Hand if statement

6. Short Hand if-else statement

Image Source: Link

Let’s take a glance at how each of those works.

If Statement

The If statement is the most fundamental decision-making statement, in which the code is executed based on whether it meets the specified condition. It has a code body that only executes if the condition in the if statement is true. The statement can be a single line or a block of code.

The if statement in Python has the subsequent syntax:

if expression Statement

#If the condition is true, the statement will be executed.

Examples for better understanding:

Example – 1

num = 5 print(num, "is a positive number.") print("This statement is true.") #When we run the program, the output will be: 5 is a positive number. This statement is true.



Example – 2

a = 25

b = 170 print("b is greater than a") output : b is greater than a

If Else Statement

This statement is used when both the true and false parts of a given condition are specified to be executed. When the condition is true, the statement inside the if block is executed; if the condition is false, the statement outside the if block is executed.

The if…Else statement in Python has the following syntax:

 if condition : #Will executes this block if the condition is true else : #Will executes this block if the condition is false

Example for better understanding:

num = 5 print("Positive or Zero") else: print("Negative number") output : Positive or Zero

If…Elif..else Statement

In this case, the If condition is evaluated first. If it is false, the Elif statement will be executed; if it also comes false, the Else statement will be executed.

The If…Elif..else statement in Python has the subsequent syntax:

if condition : Body of if elif condition : Body of elif else: Body of else

Example for better understanding:

We will check if the number is positive, negative, or zero.

num = 7 print("Positive number") elif num == 0: print("Zero") else: print("Negative number") output: Positive number

Nested IF Statement

A Nested IF statement is one in which an If statement is nestled inside another If statement. This is used when a variable must be processed more than once. If, If-else, and If…elif…else statements can be used in the program. In Nested If statements, the indentation (whitespace at the beginning) to determine the scope of each statement should take precedence.

The Nested if statement in Python has the following syntax:

if (condition1): #Executes if condition 1 is true if (condition 2): #Executes if condition 2 is true #Condition 2 ends here #Condition 1 ends here

Examples for better understanding:

Example-1

num = 8 if num == 0: print("zero") else: print("Positive number") else: print("Negative number") output: Positive number

Example-2

price=100 quantity=10 amount = price*quantity print("The amount is greater than 1000") else: if amount 800: print("The amount is between 800 and 1000") elif amount 600: print("The amount is between 600 and 1000") else: print("The amount is between 400 and 1000") elif amount == 200: print("Amount is 200") else: print("Amount is less than 200") The output : “The amount is between 400 and 1000.”

Short Hand if statement

Short Hand if statement is used when only one statement needs to be executed inside the if block. This statement can be mentioned in the same line which holds the If statement.

The Short Hand if statement in Python has the following syntax:

if condition: statement

Example for better understanding:

i=15 # One line if statement The output of the program : “i is greater than 11.”

Short Hand if-else statement

It is used to mention If-else statements in one line in which there is only one statement to execute in both if and else blocks. In simple words, If you have only one statement to execute, one for if, and one for else, you can put it all on the same line.

Examples for better understanding:

#single line if-else statement

a = 3 b = 5 output: B

#single line if-else statement, with 3 conditions

a = 3 b = 5 output: B is greater

To summarise,

· The If the condition is used to print the result when only one of the conditions listed is true or false.

· When one of the conditions is false, the If-else condition is used to print the statement.

· When there is a third possible outcome, the Elif statement is used. In a program, any number of Elif conditions can be used.

· By declaring all of the conditions in a single statement, we can reduce the number of codes that must be executed.

· Nested if statements can be used to nest one If condition inside another.

Conclusion

If you’re reading this, you’re most likely learning Python or trying to become a Python developer. Learning Python or another programming language begins with understanding the fundamental concepts that form its foundation.

By the end of this text, you should understand the various If else conditions used in python.

About The Author Prashant Sharma

Currently, I Am pursuing my Bachelors of Technology( B.Tech) from Vellore Institute of Technology. I am very enthusiastic about programming and its real applications including software development, machine learning, and data science.

Hope you like the article. If you want to connect with me then you can connect on:

Linkedin

or for any other doubts, you can send a mail to me also

The media shown in this article are not owned by Analytics Vidhya and are used at the Author’s discretion.

Related

Complete Guide To Postgresql Dblink

Introduction to PostgreSQL dblink

Whenever we need to access a database located remotely rather than on our local machine, we can establish a remote connection to that database. Using dblink in PostgreSQL, we can execute queries on the remote database and retrieve the number of rows as a result. Remote access to the database is only possible if you have permissible rights to access remote databases and sufficient information about the connection details. In this article, we will learn about the dblink method of PostgreSQL, its syntax, and examples demonstrating retrieving records situated at the remote database.

Start Your Free Data Science Course

Hadoop, Data Science, Statistics & others

dblink_connect is responsible for setting up the connection, while dblink is basically used to execute the SQL query on a remote server. Most often, the select query is used with dblink. However, any query that returns the number of rows as a return value can be used with dblink.

Three possible syntaxes of dblink are as follows –

dblink(text name_of_connection, text query_statement [, boolean fail_on_error]) dblink(text connection_string, text query_statement [, boolean fail_on_error]) dblink(text query_statement [, boolean fail_on_error])

where the parameters specified have the following purpose –

name_of_the connection is the name of the connection you want to provide. It can even be skipped if you want to create an unnamed connection.

connection_string – The string contains information about the database connection to be made with the remote database server in the libpq-style. The structure of that information string is somewhat like the following example –

hostaddr=192.16.10.11 port=5432 dbname=demoDatabaseName user=anyPostgresUser password=password_that_is_set options=-c

query_statement – It is the query statement you wish to execute on the remote database server to retrieve the rows stored there that satisfy your query specifications.

fail_on_error – This is a boolean parameter with the default value set to true when skipped or omitted in the specification as an optional parameter. When specified true or not specified, it results in an error on your database when the error has occurred on the remote database. Setting the value to false will raise a notice on your side when an error occurs on the remote database server.

Two syntaxes have two text parameters at the beginning of it and have the same signature. Hence, whenever two text parameters are supplied to the dblink method, it analyzes whether the first text parameter is any existing database connection name. If not, it considers it as a connection information string and builds up the connection accordingly.

Returned value and usage

The dblink() functions return the set of the rows as records, and you need to specify the names of the columns you need to retrieve from the remote database’s table and as the retrieving query will not have any idea about the type of columns that will be fetched, it is required to specify the name of the columns as well as the data type of the columns that will be retrieved from dblink() call’s return value. For example –

SELECT * FROM dblink('dbname=demoDatabaseName user=anyPostgresUser password=password_that_is_set options=-csearch_path=', 'select id, technologies from educba') AS demo(id integer, technologies varchar) WHERE technologies LIKE 'psql%';

As shown above, it is necessary to specify the column names in the SQL query password as a parameter to the dblink() method, and while retrieving the records from the select query on the return value from dblink(), it is necessary to mention the name of the columns and the data type of the columns so that the system will understand that the column will take that much space after retrieving. Specifying the names of the column was already compulsory in SQL syntax while using the alias. Specifying data types and column names is the norm introduced and used in PostgreSQL while using the alias. During runtime, if the column values obtained from dblink() do not align with the column count specified in the select query’s alias, an error will be thrown, indicating a mismatch in the column count between the retrieved results and the query.

Since it can become cumbersome to repeatedly mention the column names and datatypes in every dblink call, the most convenient approach is to create a view for the same purpose. In this way, we will not have to mention the datatype and name of the column every time we want to retrieve the values from the remote database. We will fire a select query on the view that we have created on our database. For example, using the same use-case as of above example, we will create a view named remote_educba_data and later, whenever required, will retrieve the data from that view instead of using dblink and all that lengthy syntax.

CREATE VIEW remote_educba_data AS SELECT * FROM dblink('dbname=demoDatabaseName user=anyPostgresUser password=password_that_is_set options=-csearch_path=', 'select id, technologies from educba') AS demo(id integer, technologies varchar) WHERE technologies LIKE 'psql%';

For later usage, we will use the following query –

SELECT * FROM remote_educba_data WHERE technologies LIKE 'psql%'; Example

Let us perform the above-mentioned solution on our terminal. Firstly, we will log in to my psql command prompt and connect to my educba database.

Now, we want to access the table named educba stored in a Postgres database using dblink in my educba database connection. As my remote database is on the same machine, my host address and port will default to 127.0.0.1, and the port will be 5432. So, we don’t need to mention them over here. My user is Postgres, and the password is ‘a’.

Firstly, let us check the contents of the existing educba table on the Postgres database using query –

SELECT * FROM educba;

Output:

Now, we will use a dblink database extension. But before that, we will have to create the dblink extension using the following query –

CREATE EXTENSION dblink;

that gives the following output –

Now, we will fire our query in the educba database to retrieve data from the Postgres database using dblink.

Open the educba database command prompt and fire the following query –

SELECT * FROM dblink('dbname=postgres user=postgres password=a', 'select id, technologies from educba') AS demo(id integer, technologies varchar) WHERE technologies LIKE 'psql%';

that gives the following output –

Now, we will use a dblink database extension. But before that, we will have to create the dblink extension using the following query –

CREATE EXTENSION dblink;

that gives the following output –

Conclusion- PostgreSQL dblink

In this way, we can use dblink to connect to remote database servers and retrieve the results from them using the dblink extension provided in Postgres. Further, we can use views to create the dblink select query structure storage so that we won’t have to call db_link() again and again in the future, specify column names, and type again.

Recommended Articles

We hope that this EDUCBA information on “PostgreSQL dblink” was beneficial to you. You can view EDUCBA’s recommended articles for more information.

Update the detailed information about How To Edit Photos In Lightroom – The Complete Guide For Beginners on the Cattuongwedding.com website. We hope the article's content will meet your needs, and we will regularly update the information to provide you with the fastest and most accurate information. Have a great day!