(0, 0)
(1, 1)
Coordinatesareusuallypassedtothelibraryas2-tuples(x,y).Rectanglesarerepresented
as4-tuples,withtheupperleftcornergivenfirst.Forexample,arectanglecoveringallof
an800x600pixelimageiswrittenas(0,0,800,600).
Palette
Thepalettemode("P")usesacolourpalettetodefinetheactualcolourforeachpixel.
Info
Youcanattachauxiliaryinformationtoanimageusingtheinfoattribute.Thisisa
dictionaryobject.
Howsuchinformationishandledwhenloadingandsavingimagefilesisuptothefile
formathandler(seethechapteronImageFileFormats).
Filters
Forgeometryoperationsthatmaymapmultipleinputpixelstoasingleoutputpixel,the
PythonImagingLibraryprovidesfourdifferentresamplingfilters.
NEAREST.Pickthenearestpixelfromtheinputimage.Ignoreallotherinput
pixels.
·
BILINEAR.Uselinearinterpolationovera2x2environmentintheinputimage.
NotethatinthecurrentversionofPIL,thisfilterusesafixedinputenvironment
whendownsampling.
·
BICUBIC.Usecubicinterpolationovera4x4environmentintheinputimage.
NotethatinthecurrentversionofPIL,thisfilterusesafixedinputenvironment
whendownsampling.
·
ANTIALIAS.(NewinPIL1.1.3).Calculatetheoutputpixelvalueusinga
high-qualityresamplingfilter(atruncatedsinc)onallpixelsthatmaycontribute
totheoutputvalue.InthecurrentversionofPIL,thisfiltercanonlybeused
withtheresizeandthumbnailmethods.
·
Pdf split pages - Split, seperate PDF into multiple files in C#.net, ASP.NET, MVC, Ajax, WinForms, WPF
Explain How to Split PDF Document in Visual C#.NET Application
break up pdf into individual pages; break a pdf password
Pdf split pages - VB.NET PDF File Split Library: Split, seperate PDF into multiple files in vb.net, ASP.NET, MVC, Ajax, WinForms, WPF
VB.NET PDF Document Splitter Control to Disassemble PDF Document
pdf split pages; break apart pdf
NotethatinthecurrentversionofPIL,theANTIALIASfilteristheonlyfilterthatbehaves
properlywhendownsampling(thatis,whenconvertingalargeimagetoasmallone).The
BILINEARandBICUBICfiltersuseafixedinputenvironment,andarebestusedfor
scale-preservinggeometrictransformsandupsamping.
C# PDF Page Insert Library: insert pages into PDF file in C#.net
files by C# code, how to rotate PDF document page, how to delete PDF page using C# .NET, how to reorganize PDF document pages and how to split PDF document in
break a pdf apart; break pdf into multiple files
VB.NET PDF Page Delete Library: remove PDF pages in vb.net, ASP.
Page: Delete Existing PDF Pages. |. Home ›› XDoc.PDF ›› VB.NET PDF: Delete PDF Page. How to VB.NET: Delete Consecutive Pages from PDF.
break pdf file into parts; a pdf page cut
TheImageModule
TheImagemoduleprovidesaclasswiththesamenamewhichisusedtorepresentaPIL
image.Themodulealsoprovidesanumberoffactoryfunctions,includingfunctionsto
loadimagesfromfiles,andtocreatenewimages.
Examples
Example:Open,rotate,anddisplayanimage
import Image
im = Image.open("bride.jpg")
im.rotate(45).show()
Example:Createthumbnails
import glob
for infile in glob.glob("*.jpg"):
file, ext = os.splitext(infile)
im = Image.open(infile)
im.thumbnail((128, 128), Image.ANTIALIAS)
im.save(file + ".thumbnail", "JPEG")
Functions
new
Image.new(mode,size)=>image
Image.new(mode,size,color)=>image
Createsanewimagewiththegivenmodeandsize.Sizeisgivenasa
2-tuple.Thecolourisgivenasasinglevalueforsingle-bandimages,
andatupleformulti-bandimages(withonevalueforeachband).If
thecolourargumentisomitted,theimageisfilledwithblack.Ifthe
colourisNone,theimageisnotinitialised.
open
Image.open(infile)=>image
Image.open(infile,mode)=>image
Opensandidentifiesthegivenimagefile.Thisisalazyoperation;the
actualimagedataisnotreadfromthefileuntilyoutrytoprocessthe
data(orcalltheloadmethod).Ifthemodeargumentisgiven,itmust
be"r".
VB.NET PDF Page Insert Library: insert pages into PDF file in vb.
Page: Insert PDF Pages. |. Home ›› XDoc.PDF ›› VB.NET PDF: Insert PDF Page. Add and Insert Multiple PDF Pages to PDF Document Using VB.
pdf format specification; break password on pdf
C# PDF Page Delete Library: remove PDF pages in C#.net, ASP.NET
Page: Delete Existing PDF Pages. Provide C# Users with Mature .NET PDF Document Manipulating Library for Deleting PDF Pages in C#.
break pdf documents; break up pdf file
Youcanuseeitherastring(representingthefilename)orafileobject.
Inthelattercase,thefileobjectmustimplementread,seek,andtell
methods,andbeopenedinbinarymode.
blend
Image.blend(image1,image2,alpha)=>image
Createsanewimagebyinterpolatingbetweenthegivenimages,using
aconstantalpha.Bothimagesmusthavethesamesizeandmode.
out = image1 * (1.0 - alpha) + image2 * alpha
Ifalphais0.0,acopyofthefirstimageisreturned.Ifalphais1.0,a
copyofthesecondimageisreturned.Therearenorestrictionsonthe
alphavalue.Ifnecessary,theresultisclippedtofitintotheallowed
outputrange.
composite
Image.composite(image1,image2,mask)=>image
Createsanewimagebyinterpolatingbetweenthegivenimages,using
themaskasalpha.Themaskimagecanhavemode"1","L",or"RGBA".
Allimagesmustbethesamesize.
eval
Image.eval(function,image)=>image
Appliesthefunction(whichshouldtakeoneargument)toeachpixelin
thegivenimage.Iftheimagehasmorethanoneband,thesame
functionisappliedtoeachband.Notethatthefunctionisevaluated
onceforeachpossiblepixelvalue,soyoucannotuserandom
componentsorothergenerators.
fromstring
Image.fromstring(mode,size,data)=>image
Createsanimagememoryfrompixeldatainastring,usingthe
standard"raw"decoder.
Image.fromstring(mode,size,data,decoder,parameters)=>image
Same,butallowsyoutouseanypixeldecodersupportedbyPIL.For
moreinformationonavailabledecoders,seethesectionWritingYour
OwnFileDecoder.
C# PDF File & Page Process Library SDK for C#.net, ASP.NET, MVC
C# File: Merge PDF; C# File: Split PDF; C# Page: Insert PDF pages; C# Page: Delete PDF pages; C# Read: PDF Text Extract; C# Read: PDF
pdf split; pdf separate pages
C# PDF Page Extract Library: copy, paste, cut PDF pages in C#.net
C#.NET PDF Library - Copy and Paste PDF Pages in C#.NET. Easy to C#.NET Sample Code: Copy and Paste PDF Pages Using C#.NET. C# programming
split pdf into individual pages; break password pdf
Notethatthisfunctiondecodespixeldata,notentireimages.Ifyou
haveanentireimageinastring,wrapitinaStringIOobject,anduse
opentoloadit.
merge
Image.merge(mode,bands)=>image
Createsanewimagefromanumberofsinglebandimages.Thebands
aregivenasatupleorlistofimages,oneforeachbanddescribedby
themode.Allbandsmusthavethesamesize.
Methods
AninstanceoftheImageclasshasthefollowingmethods.Unlessotherwisestated,all
methodsreturnanewinstanceoftheImageclass,holdingtheresultingimage.
convert
im.convert(mode)=>image
Returnsaconvertedcopyofanimage.Forthe"P"mode,thistranslates
pixelsthroughthepalette.Ifmodeisomitted,amodeischosenso
thatallinformationintheimageandthepalettecanberepresented
withoutapalette.
Thecurrentversionsupportsallpossibleconversionsbetween"L",
"RGB"and"CMYK."
Whentranslatingacolourimagetoblackandwhite(mode "L"),the
libraryusestheITU-R601-2lumatransform:
L = R * 299/1000 + G * 587/1000 + B * 114/1000
Whentranslatingagreyscaleimageintoabilevelimage(mode"1"),all
non-zerovaluesaresetto255(white).Touseotherthresholds,usethe
pointmethod.
im.convert(mode,matrix)=>image
Convertsan"RGB"imageto"L"or"RGB"usingaconversionmatrix.The
matrixisa4-or16-tuple.
ThefollowingexampleconvertsanRGBimage(linearlycalibrated
accordingtoITU-R709,usingtheD65luminant)totheCIEXYZcolour
space:
Example:ConvertRGBtoXYZ
VB.NET PDF Page Extract Library: copy, paste, cut PDF pages in vb.
Page: Extract, Copy, Paste PDF Pages. |. Home ›› XDoc.PDF ›› VB.NET PDF: Copy and Paste PDF Page. VB.NET PDF - PDF File Pages Extraction Guide.
can print pdf no pages selected; pdf no pages selected
C# PDF Page Rotate Library: rotate PDF page permanently in C#.net
featured with the functions to merge PDF files using C# .NET, add new PDF page, delete certain PDF page, reorder existing PDF pages and split PDF document in
break apart a pdf in reader; break a pdf into multiple files
rgb2xyz = (
0.412453, 0.357580, 0.180423, 0,
0.212671, 0.715160, 0.072169, 0,
0.019334, 0.119193, 0.950227, 0 )
out = im.convert("RGB", rgb2xyz)
copy
im.copy()=>image
Copiestheimage.Usethismethodifyouwishtopastethingsintoan
image,butstillretaintheoriginal.
crop
im.crop(box)=>image
Returnsarectangularregionfromthecurrentimage.Theboxisa
4-tupledefiningtheleft,upper,right,andlowerpixelcoordinate.
Thisisalazyoperation.Changestothesourceimagemayormaynot
bereflectedinthecroppedimage.Tobreaktheconnection,callthe
loadmethodonthecroppedcopy.
draft
im.draft(mode,size)
Configurestheimagefileloadersoitreturnsaversionoftheimage
thatascloselyaspossiblematchesthegivenmodeandsize.For
example,youcanusethismethodtoconvertacolourJPEGto
greyscalewhileloadingit,ortoextracta128x192versionfromaPCD
file.
NotethatthismethodmodifiestheImageobjectinplace.Iftheimage
hasalreadybeenloaded,thismethodhasnoeffect.
filter
im.filter(filter)=>image
Returnsacopyofanimagefilteredbythegivenfilter.Foralistof
availablefilters,seetheImageFiltermodule.
fromstring
im.fromstring(data)
im.fromstring(data,decoder,parameters)
Sameasthefromstringfunction,butloadsdataintothecurrent
image.
getbands
im.getbands()=>tupleofstrings
Returnsatuplecontainingthenameofeachband.Forexample,
getbandsonanRGBimagereturns("R", "G","B").
getbbox
im.getbbox()=>4-tupleorNone
Calculatestheboundingboxofthenon-zeroregionsintheimage.The
boundingboxisreturnedasa4-tupledefiningtheleft,upper,right,
andlowerpixelcoordinate.Iftheimageiscompletelyempty,this
methodreturnsNone.
getdata
im.getdata()=>sequence
Returnsthecontentsofanimageasasequenceobjectcontainingpixel
values.Thesequenceobjectisflattened,sothatvaluesforlineone
followdirectlyafterthevaluesoflinezero,andsoon.
Notethatthesequenceobjectreturnedbythismethodisaninternal
PILdatatype,whichonlysupportscertainsequenceoperations.To
convertittoanordinarysequence(e.g.forprinting),use
list(im.getdata()).
getextrema
im.getextrema()=>2-tuple
Returnsa2-tuplecontainingtheminimumandmaximumvaluesofthe
image.InthecurrentversionofPIL,thisisonlyapplicableto
single-bandimages.
getpixel
im.getpixel(xy)=>valueortuple
Returnsthepixelatthegivenposition.Iftheimageisamulti-layer
image,thismethodreturnsatuple.
histogram
im.histogram()=>list
Returnsahistogramfortheimage.Thehistogramisreturnedasalist
ofpixelcounts,oneforeachpixelvalueinthesourceimage.Ifthe
imagehasmorethanoneband,thehistogramsforallbandsare
concatenated(forexample,thehistogramforan "RGB"imagecontains
768values).
Abilevelimage(mode"1")istreatedasagreyscale("L")imagebythis
method.
im.histogram(mask)=>list
Returnsahistogramforthosepartsoftheimagewherethemaskimage
isnon-zero.Themaskimagemusthavethesamesizeastheimage,
andbeeitherabi-levelimage(mode"1")oragreyscaleimage("L").
load
im.load()
Allocatesstoragefortheimageandloadsitfromthefile(orfromthe
source,forlazyoperations).Innormalcases,youdon'tneedtocallthis
method,sincetheImageclassautomaticallyloadsanopenedimage
whenitisaccessedforthefirsttime.
offset
im.offset(xoffset,yoffset)=>image
(Deprecated)Returnsacopyoftheimagewherethedatahasbeen
offsetbythegivendistances.Datawrapsaroundtheedges.Ifyoffset
isomitted,itisassumedtobeequaltoxoffset.
Thismethodisdeprecated.Newcodeshouldusetheoffsetfunctionin
theImageChopsmodule.
paste
im.paste(image,box)
Pastesanotherimageintothisimage.Theboxargumentiseithera
2-tuplegivingtheupperleftcorner,a4-tupledefiningtheleft,upper,
right,andlowerpixelcoordinate,orNone(sameas(0,0)).Ifa4-tuple
isgiven,thesizeofthepastedimagemustmatchthesizeofthe
region.
Ifthemodesdon'tmatch,thepastedimageisconvertedtothemode
ofthisimage(seetheconvertmethodfordetails).
im.paste(colour,box)
Sameasabove,butfillstheregionwithasinglecolour.Thecolouris
givenasasinglenumericalvalueforsingle-bandimages,andatuple
formulti-bandimages.
im.paste(image,box,mask)
Sameasabove,butupdatesonlytheregionsindicatedbythemask.
Youcanuseeither"1","L"or"RGBA"images(inthelattercase,the
alphabandisusedasmask).Wherethemaskis255,thegivenimageis
copiedasis.Wherethemaskis0,thecurrentvalueispreserved.
Intermediatevaluescanbeusedfortransparencyeffects.
Notethatifyoupastean"RGBA"image,thealphabandisignored.You
canworkaroundthisbyusingthesameimageasbothsourceimage
andmask.
im.paste(colour,box,mask)
Sameasabove,butfillstheregionindicatedbythemaskwithasingle
colour.
point
im.point(table)=>image
im.point(function)image=>image
Returnsacopyoftheimagewhereeachpixelhasbeenmapped
throughthegiventable.Thetableshouldcontains256valuesperband
intheimage.Ifafunctionisusedinstead,itshouldtakeasingle
argument.Thefunctioniscalledonceforeachpossiblepixelvalue,
andtheresultingtableisappliedtoallbandsoftheimage.
Iftheimagehasmode"I"(integer)or "F"(floatingpoint),youmustuse
afunction,anditmusthavethefollowingformat:
argument * scale + offset
Example:Mapfloatingpointimages
out = im.point(lambda i: i * 1.2 + 10)
Youcanleaveouteitherthescaleortheoffset.
im.point(table,mode)=>image
im.point(function,mode)=>image
Maptheimagethroughtable,andconvertitonfly.Inthecurrent
versionofPIL,thiscanonlybeusedtoconvert"L"and"P"imagesto
"1"inonestep,e.g.tothresholdanimage.
putalpha
im.putalpha(band)
Copiesthegivenbandtothealphalayerofthecurrentimage.The
imagemustbean"RGBA"image,andthebandmustbeeither"L"or"1".
putdata
im.putdata(data)
im.putdata(data,scale,offset)
Copypixelvaluesfromasequenceobjectintotheimage,startingat
theupperleftcorner(0,0).Thescaleandoffsetvaluesareusedto
adjustthesequencevalues:
pixel = value * scale + offset
Ifthescaleisomitted,itdefaultsto1.0.Iftheoffsetisomitted,it
defaultsto0.0.
putpalette
im.putpalette(sequence)
Attachapalettetoa"P"or"L"image.Thepalettesequenceshould
contain768integervalues,whereeachgroupofthreevaluesrepresent
thered,green,andbluevaluesforthecorrespondingpixelindex.
Insteadofanintegersequence,youcanusean8-bitstring.
putpixel
im.putpixel(xy,colour)
Modifiesthepixelatthegivenposition.Thecolourisgivenasasingle
numericalvalueforsingle-bandimages,andatupleformulti-band
images.
Notethatthismethodisrelativelyslow.Formoreextensivechanges,
usepasteortheImageDrawmoduleinstead.
resize
im.resize(size)=>image
im.resize(size,filter)=>image
Returnsaresizedcopyofanimage.Thesizeargumentgivesthe
requestedsizeinpixels,asa2-tuple:(width,height).
ThefilterargumentcanbeoneofNEAREST(usenearestneighbour),
BILINEAR(linearinterpolationina2x2environment),BICUBIC(cubic
splineinterpolationina4x4environment),orANTIALIAS(a
high-qualitydownsamplingfilter).Ifomitted,oriftheimagehasmode
"1"or"P",itissettoNEAREST.
Documents you may be interested
Documents you may be interested