Monday, February 28, 2011

How to resize an image in photoshop

Resizing an image is one of the most commonly used skills in Photoshop. It's so common that even people who know virtually nothing about Photoshop still manage to use it to resize their images, which should give you an indication of how incredibly easy it is to do. However, there are some things you need to keep in mind when resizing your images, as we'll see in this Photoshop tutorial.
First, we need a photo for our lesson:
A small hut in Mexico.
This is a photo taken on a trip to Mexico. Of course, the actual photo was much larger than this, but I've resized it in Photoshop to something more suitable for the web page. How did I do that? Quite simply, really. To resize an image in Photoshop, the first thing you need to do is go up to the Image menu at the top of the screen and select "Image Size" from the list of options. This will bring up the Image Size dialog box, as shown below:
Image Size dialog box
The screenshot above of the Image Size dialog box was taken immediately after I opened the photo in Photoshop, before I resized it to the much smaller version you see above. The Image Size dialog box is divided into two main sections - "Pixel Dimensions" and "Document Size". For those of you who have already read through the sections on image resolution, this will be familiar to you, but for the benefit of those of you who simply want to learn how to resize your images, I'll be repeating some of the same information here.
Let's look more closely at the Pixel Dimensions section of the Image Size dialog box:
Pixel Dimensions section of the Image Size dialog box
The Pixel Dimensions part of the Image Size dialog box tells us two things about our image. First, to the right of the words "Pixel Dimensions" is a number, which in this case is "14.6M". This number is telling us the current file size of our image. The "M" stands for megabytes, or "millions of bytes". Knowing the file size of our image is interesting and possibly helpful in some situations, but it doesn't help us with what we want to do at the moment, which is to resize our image. For that, we need the other thing the Pixel Dimensions section is telling us - the width and height of our image.
According to what the Pixel Dimensions section is telling us here, the Mexico photo shown above was 2608 pixels wide by 1952 pixels high when I first opened it inside Photoshop. That's a decent size photo if I wanted to print it, but in this case, I needed a much smaller version of it to use on the web page. So how did I make it smaller? Simple. I changed the numbers for width and height to what I needed:
Pixel Dimensions section of the Image Size dialog box with the new values for width and height
As you can see in the screenshot above, my Mexico photo now has a width of only 450 pixels and a height of only 337 pixels. Making the change is easy. Simply double-click inside one of the two value boxes, which will highlight the number currently showing in the box, and type a new value. When you're done, click the OK button and Photoshop will resize your image to the new dimensions you've specified. It's really that simple.
You can also resize your image by a percentage of the original image size rather than typing in a specific pixel value. If you look closely at the width and height values, you'll notice that to the right of the word "pixels" is a down-pointing arrow. If you click on that arrow, a drop-down menu will appear which gives you the options to choose between "pixels" and "percent":
You can resize your images either by a specific pixel value or by a percentage of the original image size
Once you've chosen "percent" as the means in which you want to resize your image, the width and height of your image will change to a percentage rather than a pixel value. Resizing the image using a percentage is done the same way as if you were using pixel values. Just double-click inside the width or height value box once again and type in a new percentage. When you're done, click the OK button and Photoshop will resize the image to whatever percent value you entered.
You'll notice, unless you've changed the default settings, that when you double-click inside one of the value boxes and type a new number, the number in the other box changes as well. In other words, if you try to change the value for the width of your image, the height will change along with it. That's because by default, Photoshop constrains the image proportions, which is usually what you want Photoshop to do anyway. Normally, you wouldn't change the width of a photo without changing the height as well. Photoshop gives you a visual indication that the width and height of your image are linked together by displaying a black line that appears to join the width and height sections along the right side of the Pixel Dimensions section, with a small link icon to the right of the line.
You can choose to unconstrain the proportions though and change the width without it affecting the height, and vice versa, by unchecking the "Constrain Proportions" checkbox at the bottom of the Image Size dialog box. I've highlighted it below:
Constrain Proportions
As you can see, by default, the Constrain Proportions option is checked. Simply uncheck it if you want to be able to change the width and height of your image independently of each other.

Resizing And Image Quality

There's something you need to keep in mind though when it comes to resizing your image and image quality. The basic rule is, it's usually okay to make your image smaller without losing much in the way of image quality. However (and this is a big "however"), you will absolutely lose image quality if you try to make your image larger. Let's look at an example:
Here's the photo again that I used above:
A hut in Mexico
As we saw earlier, this image has dimensions of 450 pixels wide by 337 pixels high. I'm going use the Image Size dialog box to make this image 50% of this size. I do that by choosing "Percent" as the means in which I want to resize my image, and then double-click inside the "Width" value box and type "50". Since I have "Constrain Proportions" checked at the bottom of the dialog box, Photoshop will automatically change the height percentage as well to match the change I made to the width. Then I click the OK button and Photoshop resizes my image to 50% of its original size. Here's what it looks like after being made 50% smaller:
Mexico hut 50% smaller
As you can see, the image is much smaller but the quality of the image remains fairly consistent. Let's see what happens though if I take the image after being resized to 50% of it's original size and try to enlarge it back to its original size. To do that, I'll need to enlarge this image by 200%, which will make it twice as large as it is now and bring it back to its original size. Again, to do this in the Image Size dialog box, since I already have "Percent" chosen as my means of resizing the image, I simply double-click inside the "Width" dialog box and type in "200". Again, because I have "Constrain Proportions" checked, Photoshop will make the change to the height to match the change I made to the width. Once I click the OK button, Photoshop will go ahead and enlarge my image by 200%, which should bring it back to the size it was originally. Here's the image after being resized by 200%. I'll include the original image again directly below it so you can more easily compare the two versions:
Mexico hut photo after being resized by 200%
Mexico hut before resizing
The image on top is the image resized by 200% to bring it back to its original size, while the image below is the original image before we did any resizing. The resized image on top is definitely back to the same size as the original, but it sure doesn't look as good anymore, does it? We've lost a lot of detail in the image, and now it appears soft and blurry. If I was to try and enlarge it even further, the image quality would be even worse.
Here's what's happening. When you open up an image inside Photoshop and then use the Image Size dialog box to make the image smaller, Photoshop makes it smaller essentially by throwing away pixels. That's how Photoshop makes images smaller, by taking some of the pixels and throwing them out the window, so-to-speak. Photoshop is really good though at knowing which pixels it can throw away and still maintain image quality, so making our images smaller isn't usually a problem.
The problem comes in when we ask Photoshop to make our images larger. If Photoshop makes them smaller by taking some of the pixels in our image and throwing them away, how do you think it makes images larger? If you said "By adding pixels to the image?", you'd be right! Here's the stumper though. Where does Photoshop get these new pixels from that it's adding to the image? If you said "Um, I'm not sure. I guess it just kind of makes them up out of thin air", you'd be right again! And there's the problem. I don't mean that you've been right twice in a row, that's not a problem. That's great! The problem is, when Photoshop makes an image larger, it has to add pixels that were not there before, leaving Photoshop to guess as to what these new pixels are supposed to look like. Now, it uses some very complicated and advanced algorithms to guess, but the bottom line is, it's still just guessing, and it's not going to guess correctly. The larger you try to make your image, the worse your image is going to look. It will have a very soft and blurry appearance, not the crisp and sharp image you'd normally want.
So again, when resizing your image, it's okay to make your images smaller, but you should avoid making them larger at all cost unless you absolutely don't care about image quality. And who doesn't care about image quality? That's just nonsense.
We hope you found this Photoshop tutorial both helpful and enjoyable. Every tutorial at Photoshop Essentials.com is available free of charge, but we do welcome donations so we can continue adding new tutorials. If you found this and other tutorials on the website helpful and would like to make a donation, please click on the "PayPal Donate" button below:

how to change password in gmail


Changing your password

Here's how to change your password:
  1. Sign in to Gmail.
  2. Click the gear icon at the top of any Gmail page, then Mail settings, and open the Accounts and Import tab.
  3. In the 'Change account settings' section, click Change password.
  4. In the new window, enter your current password and your new password.
Make sure you create a unique password to help keep someone from breaking in to your account. Here are a few tips for creating your password, and keeping it safe:
  • Never tell anyone your password.
  • It should be easy for you to remember without being obvious for someone else to guess.
  • Never write down your password. Even though your password will look random to others, think of a way to remember it so that you don't have to write it down.
  • Change your password periodically.
  • Don't choose a dictionary word as your password. Be creative.
  • Include punctuation marks. Mix capital and lowercase letters. Use numbers. A variety of characters makes it harder to guess a password.
If your password isn't working, you'll need to go through our password recovery process. Google Apps users, please contact your organization's IT admin for help with password recovery.

how to export a function from c# dll

Introduction

In this article, I would like to explain how to create and use DLLs in C Sharp. Before writing code, we will examine some basics of a DLL in the .NET framework; for example, how it's loaded in the process address space, how CLR is initialized, and the mechanism behind the screen. First, we will talk about MSCorEE.dll; you will find this guy in the %windir%\system32\ directory. MSCorEE.dll stands for Microsoft Component object runtime Execution Engine. The existence of this file tells you that you have installed the .NET framework in your system. This DLL is responsible for initializing the CLR.
Whenever you create an assembly, the compiler/linker emits the following 6-byte x86 stub function into the PE file's .text section:
JMP _CorExeMain for Exe or JMP _CorDllMain for Dll.
Figure 1 shows the Portable Executable (PE) file format. This stub function is implemented inside the MSCorEE.dll. So, this dll must be referenced somewhere in the PE file. Yes, your guess is right; it's referenced in the .idata section of the PE file. The .idata section is used to refer import libraries for assembly.

Figure 1—The PE file format.
We have given all the hints and clues to the Windows loader, so here we go.... When the managed assembly file is invoked, the Windows loader completes the following steps:
  1. Loads the PE file, parses the .idata section, and loads MSCorEE.dll (if it's not already loaded) into the process's address space.
  2. Takes the address of _CorExeMain in the case of an Exe assembly, or _CorDllMain in the case of a DLL assembly function, inside the MSCoreEE.dll.
  3. Using the address from Step 2, the Windows loader fixes the stub function JMP instruction (from the .text section PE).
At this point, the process's primary thread starts executing the stub function; that is, it jumps to _CorExeMain for Exe or _CorDllMain for Dll in the MSCorEE.dll. The _CorExeMain or _CorDllMain initializes the CLR and looks for a managed entry point from the assembly's CLR header and starts executting. Here the IL code for the method is compiled into native CPU instructions and the CLR jumps to native code. That's it; the managed applications code is running.
The framework differentiates between managed executive and managed DLL files because of the stub function stored in the .text section of the PE file. For Exe, the stub function is JMP _CorExeMain and for Dll the stub function is JMP _CorDllMain. The Windows loader differentiates this function and fixes the corresponding address from the MSCorEE.dll.
I think now we know how a managed exe/dll loads in the process address space and how CLR gets initialized. Okay, time for coding. Here we develop a small DLL and a test container for that. This DLL will export three functions, each from one class in a namespace.
Open a new C# WindowsApplication project in Visual Studio .NET. Name the Project MathFunctions.
Add the following three classes to this project. Name them something like AddClass.cs, MultiClass.cs, and FactorialClass.cs.
Listing 1. AddClass.cs
using System;

namespace MathFunctions
{
  public class AddClass
  {
    public static int Add(int a, ant b)
    {
      return (a+b);
    }
  }
}
Listing 2. MultiClass.cs
using System;

namespace MathFunctions
{
  public class MultiClass
  {
    public static int Multiply(int a, int b)
    {
      return (a*b);
    }
  }
}
Listing 3. FactorialClass.cs
namespace MathFunctions
{
  public class FactorialClass
  {
    public static int Factorial(int i)
    {
      return((i <= 1) ? 1 : (i * Factorial(i-1)));
    }

  }
}
Our idea is to export AddClass::Add, MultiClass:: Multiply, and FactorialClass::Factorial from the namespace MathFunctions. That's it; we're finished coding.
Go to the command line and type the following.
CSC /target:library /out:MyFunctions.dll AddClass.cs
     MultiClass.cs FactorialClass.cs
Go to the command line option /target:library and ask the C Sharp Compiler/Linker to output a DLL instead of an EXE. It's possible to have a different name for the DLL; for example, /out:MyFunctions.dll directs the compiler to output the DLL with the name MyFunctionsLib; otherwise, it will take the default name from the first .cs file. Here, it's AddClass.dll.
Now comes the test container for this DLL. Create a new WindowsApplication project by right-clicking the solution in the Solution Explorer pane. Name it DllTestApp.
Add the following line to the Using section.
using MathFunctions;
Add the following code to the click of button1.
private void button1_Click(object sender, System.EventArgs e)
{
int add = AddClass.Add(125,125);
  int mul = MultiClass.Multiply(25,25);
  int fac = FactorialClass.Factorial(5);

  string str = "Addition result = " + add.ToString() + "\n"
       + "Multiplication result = " + mul.ToString() + "\n"
       + "Factorial result = " + fac.ToString();

  MessageBox.Show(str, "MyDllTestDialog");

}
To refer to the DLL in our project, right-click the project's reference and click Add Reference. This displays tabbed panes that list the various types of components and projects you can browse. On the .NET tab, click the Brows button and browse for the DLL to which you want to refer (here, MyFunctions.dll), and click OK.