芝麻web文件管理V1.00
编辑当前文件:/home/krishnamexports/www/panel/fckeditor/editor/filemanager/connectors/cfm/image.cfc
paths = arrayNew(1); paths[1] = expandPath("metadata-extractor-2.3.1.jar"); loader = createObject("component", "javaloader.JavaLoader").init(paths); //at this stage we only have access to the class, but we don't have an instance JpegMetadataReader = loader.create("com.drew.imaging.jpeg.JpegMetadataReader"); myMetaData = JpegMetadataReader.readMetadata(inFile); directories = myMetaData.getDirectoryIterator(); while (directories.hasNext()) { currentDirectory = directories.next(); tags = currentDirectory.getTagIterator(); while (tags.hasNext()) { currentTag = tags.next(); if (currentTag.getTagName() DOES NOT CONTAIN "Unknown") { //leave out the junk data queryAddRow(retQry); querySetCell(retQry,"dirName",replace(currentTag.getDirectoryName(),' ','_','ALL')); tagName = replace(currentTag.getTagName(),' ','','ALL'); tagName = replace(tagName,'/','','ALL'); querySetCell(retQry,"tagName",tagName); querySetCell(retQry,"tagValue",currentTag.getDescription()); } } } return retQry;
resizedImage = CreateObject("java", "java.awt.image.BufferedImage"); at = CreateObject("java", "java.awt.geom.AffineTransform"); op = CreateObject("java", "java.awt.image.AffineTransformOp"); w = img.getWidth(); h = img.getHeight(); if (preserveAspect and cropToExact and newHeight gt 0 and newWidth gt 0) { if (w / h gt newWidth / newHeight){ newWidth = 0; } else if (w / h lt newWidth / newHeight){ newHeight = 0; } } else if (preserveAspect and newHeight gt 0 and newWidth gt 0) { if (w / h gt newWidth / newHeight){ newHeight = 0; } else if (w / h lt newWidth / newHeight){ newWidth = 0; } } if (newWidth gt 0 and newHeight eq 0) { scale = newWidth / w; w = newWidth; h = round(h*scale); } else if (newHeight gt 0 and newWidth eq 0) { scale = newHeight / h; h = newHeight; w = round(w*scale); } else if (newHeight gt 0 and newWidth gt 0) { w = newWidth; h = newHeight; } else { retVal = throw( retVal.errorMessage); return retVal; } resizedImage.init(javacast("int",w),javacast("int",h),img.getType()); w = w / img.getWidth(); h = h / img.getHeight(); op.init(at.getScaleInstance(javacast("double",w),javacast("double",h)), rh); // resizedImage = op.createCompatibleDestImage(img, img.getColorModel()); op.filter(img, resizedImage); imgInfo = getimageinfo(resizedImage, ""); if (imgInfo.errorCode gt 0) { return imgInfo; } cropOffsetX = max( Int( (imgInfo.width/2) - (newWidth/2) ), 0 ); cropOffsetY = max( Int( (imgInfo.height/2) - (newHeight/2) ), 0 ); // There is a chance that the image is exactly the correct // width and height and don't need to be cropped if ( preserveAspect and cropToExact and (imgInfo.width IS NOT specifiedWidth OR imgInfo.height IS NOT specifiedHeight) ) { // Get the correct offset to get the center of the image cropOffsetX = max( Int( (imgInfo.width/2) - (specifiedWidth/2) ), 0 ); cropOffsetY = max( Int( (imgInfo.height/2) - (specifiedHeight/2) ), 0 ); cropImageResult = crop( resizedImage, "", "", cropOffsetX, cropOffsetY, specifiedWidth, specifiedHeight ); if ( cropImageResult.errorCode GT 0) { return cropImageResult; } else { resizedImage = cropImageResult.img; } } if (outputFile eq "") { retVal.img = resizedImage; return retVal; } else { saveImage = writeImage(outputFile, resizedImage, jpegCompression); if (saveImage.errorCode gt 0) { return saveImage; } else { return retVal; } }
if (fromX + newWidth gt img.getWidth() OR fromY + newHeight gt img.getHeight() ) { retval = throw( "The cropped image dimensions go beyond the original image dimensions."); return retVal; } croppedImage = img.getSubimage(javaCast("int", fromX), javaCast("int", fromY), javaCast("int", newWidth), javaCast("int", newHeight) ); if (outputFile eq "") { retVal.img = croppedImage; return retVal; } else { saveImage = writeImage(outputFile, croppedImage, jpegCompression); if (saveImage.errorCode gt 0) { return saveImage; } else { return retVal; } }
rotatedImage = CreateObject("java", "java.awt.image.BufferedImage"); at = CreateObject("java", "java.awt.geom.AffineTransform"); op = CreateObject("java", "java.awt.image.AffineTransformOp"); iw = img.getWidth(); h = iw; ih = img.getHeight(); w = ih; if(arguments.degrees eq 180) { w = iw; h = ih; } x = (w/2)-(iw/2); y = (h/2)-(ih/2); rotatedImage.init(javacast("int",w),javacast("int",h),img.getType()); at.rotate(arguments.degrees * 0.0174532925,w/2,h/2); at.translate(x,y); op.init(at, rh); op.filter(img, rotatedImage); if (outputFile eq "") { retVal.img = rotatedImage; return retVal; } else { saveImage = writeImage(outputFile, rotatedImage, jpegCompression); if (saveImage.errorCode gt 0) { return saveImage; } else { return retVal; } }
if (outputFile eq "") { retVal = throw( "The convert method requires a valid output filename."); return retVal; } else { saveImage = writeImage(outputFile, img, jpegCompression); if (saveImage.errorCode gt 0) { return saveImage; } else { return retVal; } }
/* JPEG output method handles compression */ out = createObject("java", "java.io.BufferedOutputStream"); fos = createObject("java", "java.io.FileOutputStream"); fos.init(tempOutputFile); out.init(fos); JPEGCodec = createObject("java", "com.sun.image.codec.jpeg.JPEGCodec"); encoder = JPEGCodec.createJPEGEncoder(out); param = encoder.getDefaultJPEGEncodeParam(img); param.setQuality(quality, false); encoder.setJPEGEncodeParam(param); encoder.encode(img); out.close();
flippedImage = CreateObject("java", "java.awt.image.BufferedImage"); at = CreateObject("java", "java.awt.geom.AffineTransform"); op = CreateObject("java", "java.awt.image.AffineTransformOp"); flippedImage.init(img.getWidth(), img.getHeight(), img.getType()); if (direction eq "horizontal") { at = at.getScaleInstance(-1, 1); at.translate(-img.getWidth(), 0); } else { at = at.getScaleInstance(1,-1); at.translate(0, -img.getHeight()); } op.init(at, rh); op.filter(img, flippedImage); if (outputFile eq "") { retVal.img = flippedImage; return retVal; } else { saveImage = writeImage(outputFile, flippedImage, jpegCompression); if (saveImage.errorCode gt 0) { return saveImage; } else { return retVal; } }
// initialize the blur filter variables.blurFilter.init(arguments.blurAmount); // move the source image into the destination image // so we can repeatedly blur it. destImage = srcImage; for (i=1; i lte iterations; i=i+1) { // do the blur i times destImage = variables.blurFilter.filter(destImage); } if (outputFile eq "") { // return the image object retVal.img = destImage; return retVal; } else { // write the image object to the specified file. saveImage = writeImage(outputFile, destImage, jpegCompression); if (saveImage.errorCode gt 0) { return saveImage; } else { return retVal; } }
// initialize the sharpen filter variables.sharpenFilter.init(); destImage = variables.sharpenFilter.filter(srcImage); if (outputFile eq "") { // return the image object retVal.img = destImage; return retVal; } else { // write the image object to the specified file. saveImage = writeImage(outputFile, destImage, jpegCompression); if (saveImage.errorCode gt 0) { return saveImage; } else { return retVal; } }
// initialize the posterize filter variables.posterizeFilter.init(arguments.amount); destImage = variables.posterizeFilter.filter(srcImage); if (outputFile eq "") { // return the image object retVal.img = destImage; return retVal; } else { // write the image object to the specified file. saveImage = writeImage(outputFile, destImage, jpegCompression); if (saveImage.errorCode gt 0) { return saveImage; } else { return retVal; } }
// load objects bgImage = CreateObject("java", "java.awt.image.BufferedImage"); fontImage = CreateObject("java", "java.awt.image.BufferedImage"); overlayImage = CreateObject("java", "java.awt.image.BufferedImage"); Color = CreateObject("java","java.awt.Color"); font = createObject("java","java.awt.Font"); font_stream = createObject("java","java.io.FileInputStream"); ac = CreateObject("Java", "java.awt.AlphaComposite"); // set up basic needs fontColor = Color.init(javacast("int", rgb.red), javacast("int", rgb.green), javacast("int", rgb.blue)); if (fontDetails.fontFile neq "") { font_stream.init(arguments.fontDetails.fontFile); font = font.createFont(font.TRUETYPE_FONT, font_stream); font = font.deriveFont(javacast("float",arguments.fontDetails.size)); } else { font.init(fontDetails.fontName, evaluate(fontDetails.style), fontDetails.size); } // get font metrics using a 1x1 bufferedImage fontImage.init(1,1,img.getType()); g2 = fontImage.createGraphics(); g2.setRenderingHints(getRenderingHints()); fc = g2.getFontRenderContext(); bounds = font.getStringBounds(content,fc); g2 = img.createGraphics(); g2.setRenderingHints(getRenderingHints()); g2.setFont(font); g2.setColor(fontColor); // in case you want to change the alpha // g2.setComposite(ac.getInstance(ac.SRC_OVER, 0.50)); // the location (arguments.fontDetails.size+y) doesn't really work // the way I want it to. g2.drawString(content,javacast("int",x),javacast("int",arguments.fontDetails.size+y)); if (outputFile eq "") { retVal.img = img; return retVal; } else { saveImage = writeImage(outputFile, img, jpegCompression); if (saveImage.errorCode gt 0) { return saveImage; } else { return retVal; } }
at = CreateObject("java", "java.awt.geom.AffineTransform"); op = CreateObject("java", "java.awt.image.AffineTransformOp"); ac = CreateObject("Java", "java.awt.AlphaComposite"); gfx = originalImage.getGraphics(); gfx.setComposite(ac.getInstance(ac.SRC_OVER, alpha)); at.init(); // op.init(at,op.TYPE_BILINEAR); op.init(at, rh); gfx.drawImage(wmImage, op, javaCast("int",arguments.placeAtX), javacast("int", arguments.placeAtY)); gfx.dispose(); if (outputFile eq "") { retVal.img = originalImage; return retVal; } else { saveImage = writeImage(outputFile, originalImage, jpegCompression); if (saveImage.errorCode gt 0) { return saveImage; } else { return retVal; } }
// convert the image to a specified BufferedImage type and return it var width = bImage.getWidth(); var height = bImage.getHeight(); var newImage = createObject("java","java.awt.image.BufferedImage").init(javacast("int",width), javacast("int",height), javacast("int",type)); // int[] rgbArray = new int[width*height]; var rgbArray = variables.arrObj.newInstance(variables.intClass, javacast("int",width*height)); bImage.getRGB( javacast("int",0), javacast("int",0), javacast("int",width), javacast("int",height), rgbArray, javacast("int",0), javacast("int",width) ); newImage.setRGB( javacast("int",0), javacast("int",0), javacast("int",width), javacast("int",height), rgbArray, javacast("int",0), javacast("int",width) ); return newImage;