How to Tell if jpg File Is in Cymk in Asp Upload
8.ane CMYK-to-RGB Conversion
8.2 Image Resolution
8.3 Access to Private Pixels
8.four Progressive JPEGs
viii.5 Brightness, Dissimilarity and Saturation
viii.6 Filters
8.vii Blush Key
Most digital images we deal with are RGB. That is, the color of each pixel in those images is represented by three components -- reddish, green and blue (RGB), which correspond to the three cathode emitters in the monitor. In images intended for impress, on the other hand, the pixels are represented by four colorants -- cyan, magenta, yellow and blackness (CMYK), which correspond to the four principal ink colors used in printers.JPEG and TIFF images created in the CMYK color space cannot be viewed over the Web, Internet Explorer shows them as the "red X" icon. To enable CMYK paradigm viewing, AspJpeg 1.5+ offers a new method, ToRGB, which converts CMYK images to the RGB color infinite.
Converting CMYK to RGB is non a fiddling task and at that place is no single "right" way to do it. To achieve reasonably good colour reproduction, the ToRGB method performs a serial of complex non-linear colour transformations based on profiles, the standard color space definitions established by the International Color Consortium (ICC). For more data on ICC profiles, visit www.color.org.
CMYK-to-RGB conversion is a very CPU-intensive process. Information technology is therefore important to phone call the ToRGB method later on the image size has been reduced:
VB Script:
' Fast
Jpeg.Width = Jpeg.OriginalWidth / 2
Jpeg.Height = Jpeg.OriginalHeight / ii
Jpeg.ToRGB' Slow
Jpeg.ToRGB
Jpeg.Width = Jpeg.OriginalWidth / 2
Jpeg.Acme = Jpeg.OriginalHeight / 2
Jpeg.ToRGB just has effect if the electric current image is in CMYK or grayscale color spaces. If the image is already an RGB one, the method does nothing.
To see the CMYK-to-RGB functionality in action, run Live Demo #3.
Image resolution is information embedded in an image specifying the print quality of this image should it be printed. Resolution is commonly expressed in dots-per-inch (DPI). 72 DPI or 96 DPI images are known as low-resolution and 300 DPI and above equally high-resolution.Most image viewers, such as your Web browser, ignore the resolution information and but use the pixel size of the image for screen rendering. Advanced epitome management and print systems such equally Photoshop do utilise image resolution to compute the right size of the image on paper when printed. Note that resolution data is not always embedded in an paradigm. If that is the case, information technology should exist causeless to exist 72 DPI.
AspJpeg 1.5+ enables you to retrieve the resolution information from images, and too prepare new resolution. The properties OriginalResolutionX and OriginalResolutionY return the current DPI resolution along the horizontal and vertical coordinates, respectively. If these properties each return 1, information technology means the resolution is not embedded in the prototype. Quite perhaps, all the same, this data is nonetheless present, only in the form of EXIF tags (read more than near EXIF in the previous affiliate.)
The following code snippet attempts to retrieve the X and Y resolutions from an arbitrary paradigm:
<%
path = "c:\path\image.jpg"jpeg.Open(path)
XRes = jpeg.OriginalResolutionX
YRes = jpeg.OriginalResolutionYIf XRes = ane and YRes = 1 Then
' Expect amongst EXIF tags
Set Info = jpeg.OpenInfo(path)If Info("XResolution") <> "" Then
XRes = Info("XResolution")
YRes = Info("YResolution")
Else
Response.Write "Resolution info not found."
End if
Terminate If
%>To set new resolution, apply the properties ResolutionX and ResolutionY, as follows:
...
Jpeg.ResolutionX = 72
Jpeg.ResolutionY = 72
...
Jpeg.Save path
Starting with Version ane.5, AspJpeg is capable of setting and retrieving individual pixels of an epitome via the default Pixels property of the primary ASPJpeg object. This property accepts two arguments (Ten, Y) which specify the location of the pixel to be set or retrieved. The property returns, or is assigned, an array of colour components for this pixel. In case of an RGB image, the array must comprise exactly three elements. The number of color components in an epitome tin exist retrieved via the property Jpeg.OriginalComponents.Since Pixels is the default holding, it can be omitted. The following code snippets demonstrate this technique:
VB Script:
' Set pixel (20, fifty) to greenishC#:
jpeg.Pixels(20, 50) = array(0, 255, 0)' Remember pixel (30, 40). The discussion "Pixels" is optional
arr = jpeg(30, twoscore)
for i = 0 to jpeg.OriginalComponents - one
Response.Write arr(i) & " "
Next
// Set pixel (20, thirty) to orange
Object [] arr = new Object[3];
arr[0] = (Object)255;
arr[one] = (Object)128;
arr[2] = (Object)0;objJpeg[20, thirty] = arr;
// Think pixel (fifteen, 20)
Assortment arr2 = (Array)objJpeg[fifteen, 20];
for( int i = 0; i < objJpeg.OriginalComponents; i++ )
Response.Write( arr2.GetValue(i).ToString() + " " );
A progressive JPEG is an equivalent of "interlaced" GIF. Such an image can be displayed in total size even if but partially downloaded, although in lower quality. As more and more data arrives, the epitome progressively becomes sharper and sharper until the unabridged prototype has been downloaded. This feature makes progressive images attractive in a slow-connectedness surround.8.5 Effulgence, Contrast and SaturationWith AspJpeg 1.5+, you lot can create progressive JPEGs past setting the Progressive holding to True:
Jpeg.Progressive = Truthful
...
Jpeg.Salvage pathNote that Netscape is currently the only major browser supporting gradual rendering of progressive JPEGs, other browsers just display the entire image at in one case after it has been fully downloaded.
8.6 FiltersStarting with version 1.vii, AspJpeg is capable of adjusting the brightness, contrast and saturation of an image using the multi-purpose Adapt method. This method expects 2 parameters: the operation code and the functioning-specific value.
To adapt effulgence, 1 is passed as the commencement parameter and a brightness value in the range [-1, one] is passed as the 2nd parameter. A value greater than 0 increases effulgence, a value less than 0 decreases it:
jpeg.Adjust ane, 0.05
To adjust contrast, 2 is passed equally the outset parameter and a contrast value in the range [0.001, 5] is passed equally the 2nd parameter. A value greater than ane increases constrast, a value less than i decreases it:
jpeg.Adjust ii, one.2
To adjust saturation, 3 is passed as the showtime parameter and a saturation value in the range [-1, i] is passed as the 2nd parameter. A value greater than 0 increases saturation, a value less than 0 decreases it:
jpeg.Adjust 3, -0.two
The Adjust method is only applicative to RGB images.
Note: As of Version 2.6, the Conform method is obsolete. ApplyFilter, a more versatile method described in the following department, should be used instead.
eight.vii Chroma Key
As of Version ii.6, AspJpeg offers several common image filters such every bit brightness, contrast, saturation, blur, sharpness, edge detection and others via a single method, ApplyFilter. This method accepts three arguments: the Filter ID, and 2 filter-specific parameters. The starting time parameter is a number, the 2d is an optional variant value. Some filters require the 1st or 2d parameter only, others require both, still others none at all.
The following tabular array summarizes all filters currently supported, every bit applied to the image shown on the right.
Name Filter Parameter ane Parameter 2 Sample Output and Notes Brightness 1 Brightness amount, a number in the range [-255, 255] Not used ![]()
Jpeg.ApplyFilter ane, 100
Contrast 2 Dissimilarity amount, a number in the range [-255, 255] Non used ![]()
Jpeg.ApplyFilter 2, 100
Saturation 3 Saturation amount, a number in the range [-100, 100] Not used ![]()
Jpeg.ApplyFilter three, -50
Gaussian mistiness 4 Sigma, a positive number Kernel size, an odd number between 3 and 21 (7 past default) ![]()
Jpeg.ApplyFilter 4, three, five
Sharpen five 0 for less sharpening, 1 for more than sharpening Not used ![]()
Jpeg.ApplyFilter 5, 0
Generic Convolution half dozen Not used Kernel matrix, an array of numbers specifying the relative weights of neighboring pixels to be applied to each pixel of the image. The array's length must exist a square number from the set up [nine, 25, 49, ..., 441] ![]()
Jpeg.ApplyFilter 6, 0, Array(-2, -i, 0, -one, i, i, 0, 1, ii)
Sharpen, mistiness, emboss and many other filters are based on a generic convolution transformation. The kernel in this example implements an emboss filter.
Threshold 7 Threshold value in the range [0, 255] Non used ![]()
Jpeg.ApplyFilter 7, 150
Converts the image to monochrome (strictly black and white.)
Border Detection 8 Non used Not used ![]()
Jpeg.ApplyFilter viii, 0
Implements Sobel edge detection algorithm. Converts the image to grayscale.
Notation: the ApplyFilter method cannot be used with CMYK images.
Chroma Key refers to a visual effect where two images are combined into one in such a manner that the monochromatic (usually green or blue) background of the first image is replaced with the second paradigm, while its foreground subject remains intact. It is normally used for weather forecast broadcasts, among other areas.
![]()
As of Version ii.half dozen, AspJpeg implements the chroma cardinal issue via the method DrawImageChromaKey of its Canvas object. This method is similar to the DrawImage method in that information technology draws ane prototype on top of another, just it does and then while removing the monochromatic background of the epitome being fatigued.
The DrawImageChromaKey method expects 8 arguments. The first three are the aforementioned as in DrawImage: the X and Y coordinates and an instance of the AspJpeg object representing the image to be fatigued on the electric current image. The other 5 arguments control the handling of the monochromatic groundwork of the image being fatigued: the RGB values of the key colour (the predominant color of the background), and two color distances Dist1 and Dist2. All pixels with the colors closer to the cardinal color than Dist1 are fabricated fully transparent. All pixels with the colors farther from the key color than Dist2 are made fully opaque. All pixels in betwixt are fabricated semi-transparent for better blending. All these arguments are to be called past trial and mistake for each groundwork.
The image in a higher place was created using the following code sample:
VB Script:
<%
Fix BG = Server.CreateObject("Persits.Jpeg")' Open up background image
BG.Open Server.MapPath(".") & "/../images/gym.jpg"' Open image with subject confronting monochromatic groundwork
Set Jpeg = Server.CreateObject("Persits.Jpeg")
Jpeg.Open Server.MapPath(".") & "/../images/greenscreen.jpg"' Describe it on the background. Remove "green screen".
' Key colour's RGB values: (60, 205, 72)
' Color distances: 20, 80
BG.Canvas.DrawImageChromaKey 0, 0, Jpeg, 60, 205, 72, twenty, lxxxBG.Relieve Server.MapPath("blush.jpg")
%>C#:
// Compute paths to source images
String strBGPath = Server.MapPath("../images/gym.jpg");
String strPath = Server.MapPath("../images/greenscreen.jpg");IASPJpeg objBG = new ASPJpeg();
// Open groundwork image
objBG.Open( strBGPath );// Open paradigm with subject field confronting monochromatic background
IASPJpeg objJpeg = new ASPJpeg();
objJpeg.Open( strPath );// Depict it on the background. Remove "green screen".
// Key color'south RGB values: (lx, 205, 72)
// Color distances: twenty, 80
objBG.Canvas.DrawImageChromaKey( 0, 0, (ASPJpeg)objJpeg, 60, 205, 72, 20, 80 );objBG.Salve( Server.MapPath("blush.jpg") );
FramedImage.Src = "chroma.jpg";
Click the links below to run this lawmaking sample:
http://localhost/aspjpeg/manual_08/08_chroma.asp
http://localhost/aspjpeg/manual_08/08_chroma.aspx![]()
![]()
![]()
![]()
| Advanced Image Management for ASP and .Internet | All Rights Reserved. AspJpeg is a trademark of Persits Software, Inc. |
Source: http://www.aspjpeg.com/manual_08.html
Post a Comment for "How to Tell if jpg File Is in Cymk in Asp Upload"