i want to convert the PDF to image.But when the out put image generate it's get blur from original.Here is code
$uploadfile = ".pdf[53]";
$img = new Imagick($uploadfile);
$img->setResolution(300,300);
$img->resampleImage(150,150,imagick::FILTER_UNDEFINED,1);
$img->resizeImage(512,700,Imagick::FILTER_LANCZOS,0);
$img->setImageFormat('jpeg');
$img->setImageUnits(imagick::RESOLUTION_PIXELSPERINCH);
$img->writeImage ( "p-53.jpeg" );
Can you please help me.
Thank you.
Remove the resample and the resize calls and see what you get. It looks like you are shrinking it and then upsizing it.
edit: setResolution(300,300) is too late -- the image has already been rendered. Do it like this:
$im = new Imagick();
$im->setResolution( 300, 300 );
$im->readImage( $uploadfile );
Related
I am using OpenCV.js in Ionic 3 to make a scanner app.
I have a .ts file with rotate function like this:
rotateRight() {
let src = cv.imread('img');
let dst = new cv.Mat();
let dsize = new cv.Size(src.rows, src.cols);
let center = new cv.Point(src.cols / 2, src.rows / 2);
let M = cv.getRotationMatrix2D(center, -90, 1);
cv.warpAffine(src, dst, M, dsize, cv.INTER_LINEAR, cv.BORDER_CONSTANT, new cv.Scalar());
cv.imshow('canvasOutput', dst);
src.delete(); dst.delete(); M.delete();
}
And I have code like this in .html file with img source to get and canvas to display new image after processing:
<img id="img" [src]="picture" *ngIf="picture" />
<canvas id="canvasOutput" ></canvas>
My problem is I just want to display only one image in my .html file, I want after processing the new image will display in the img source from the begin instead of having another display like canvas.
Is there any way to do that?
Thanks for helping!
After asking I found the answer by myself.
Firstly, get element canvasOutput and img from HTML, then change image's source to canvasOutput with base64 format:
var canvasOutput = document.getElementById('canvasOutput') as HTMLCanvasElement;
let picture = document.getElementById("img") as HTMLImageElement;
picture.src = canvasOutput.toDataURL();
Lastly set 's style to visibility: hidden to hide canvas tag.
I want to copy an image from camera to anothe imagebox using ROI. I have searched a lot references about ROI but it still doesn't work. Anybody can help me, please ?
These are what I have done
Image<Bgr, Byte> sourceImage1 = CaptureCam1.QueryFrame();
SourceImageBox.Image = sourceImage1;
ImageCopy = new Image<Bgr, Byte>(Template_Box.Width, Template_Box.Height);
sourceImage1.ROI = new Rectangle(SourceImageBox.Location.X, SourceImageBox.Location.Y, SourceImageBox.Width, SourceImageBox.Height);
sourceImage1.CopyTo(ImageCopy);
Template_Box.Image = ImageCopy;
You should use it like below:
sourceImage1.ROI = new Rectangle(SourceImageBox.Location.X, SourceImageBox.Location.Y, SourceImageBox.Width, SourceImageBox.Height);
Template_Box.Image = sourceImage1.clone();
This question already has an answer here:
Dart svg ImageElement is not showing up
(1 answer)
Closed 9 years ago.
I am trying to show an (interchangeable) image as background to an ellipse or other various things I will manipulate later.
The problem is that I can't find how to load the image properly.
My code:
DivElement div = querySelector("#mainDiv");
svg.SvgElement svgElement = new svg.SvgSvgElement();
div.append(svgElement);
//div.setAttribute("background-color", "yellow");
svg.RectElement rec = new svg.RectElement();
rec.setAttribute("x", "0");
rec.setAttribute("y", "0");
rec.setAttribute("width",div.clientWidth.toString());
rec.setAttribute("height", div.clientHeight.toString());
//svgElement.children.add(rec);
Ellipse ell = new Ellipse() //my class. shows and allow to move it
..cx = 100
..cy= 100
..rx= 50
..ry= 50;
svgElement.children.add(ell.ellipse);
ImageElement image = new ImageElement(src: "2.jpg");
image.onLoad.listen((e) {
svgElement.children.add(image);
});
As you can see there is a Rectangle, which was my first attempt to show the image with various attributes (background-image, background..), then I thought to add the ImageElement directly after onLoad. Both Failed.
My next step should be to try with patterns, but I'm not sure if I can translate in Dart what I've read for javascript.
Edit: It would be nice to be able to load the image as well, so that I can read attributes like dimensions.
Edit2: Since I can't add an answer, here is the code I made by checking the "duplicate" original one.
import 'dart:svg' as svg;
//...
DivElement div = querySelector("#mainDiv");
svg.SvgElement svgElement = new svg.SvgSvgElement();
div.append(svgElement);
Ellipse ell = new Ellipse()
..cx = 100
..cy= 100
..rx= 50
..ry= 50;
svg.ImageElement image = new svg.ImageElement();
svgElement.children.add(image);
image.setAttribute('x', '0');
image.setAttribute('y', '0');
image.setAttribute('width', '100%');
image.setAttribute('height', '100%');
image.getNamespacedAttributes('http://www.w3.org/1999/xlink')['href'] = '2.jpg';
svgElement.children.add(ell.ellipse);
I haven't tried it but I assume that the onLoad event will not fire before the element isn't added to the DOM.
You should add the image just after creating the element.
You could alternatively set display: none and change to display: auto when onLoad fires.
Above is my screenshot I am getting while displaying the wait screen using ActivityIndicatorView. Any idea why my spinner image is being displayed within a narrow strip?
My code is:
ActivityIndicatorView act = new ActivityIndicatorView(Field.FIELD_HCENTER);
Bitmap spinImage = Bitmap.getBitmapResource("img/spinner.jpg");
act.createActivityImageField(spinImage, 9,Field.FIELD_HCENTER );
LabelField label = new LabelField(message);
DialogFieldManager manager = new DialogFieldManager();
popup = new PopupScreen(manager);
manager.addCustomField(label);
manager.addCustomField(act);
EDIT: Spinner Image
EDIT 2: Full spinner image only when No. of frames = 1 and image = spinner.gif
You didn't upload the img/spinner.jpg, so I assumed that the image has only one frame. Try replacing the line
act.createActivityImageField(spinImage, 9,Field.FIELD_HCENTER );
with the line
act.createActivityImageField(spinImage, 1, Field.FIELD_HCENTER);
Also check the API documentation carefully.
Thanks Nate and Rupak. I leave this for others facing similar issue. I simply had to use the width of the image frames be the width of a frame multiplied by the total number of frames. Reference here
I set the number of frames 4 and image:
I'm using imagemagick to resize uploaded files but while they're processing I want to show a rotating gif wheel to the user where the thumbnail would normally be. I serve about 7 sizes of thumbs and would like the wheel to remain at it's 32x32 size in the middle, that's the simple bit.
What I need to know is, can I do the above while still retaining the animation
Example:
This Image:
Starting at this size
With Animation
Check out this fiddle, it might contain what you want: http://jsfiddle.net/TGdFB/1/
It uses jQuery, but should be easily adaptable...
Ended up doing this manually by Photoshop after not being able to find an automated way of doing this through imagemagick. I found the 'coalesce' flag but not much else.
there is a solution in php witch i use to watermark gif animated images ....
it create an black bacground put an image on it and then put watermark ...
watermarkpath = 'path to wathermarkimage.jpg|gif|png';
$imagepath= 'path to the image';
$watermark = new Imagick($watermarkpath);
$GIF = new Imagick();
$GIF->setFormat("gif");
$animation = new Imagick($imagepath);
foreach ($animation as $frame) {
$iWidth = $frame->getImageWidth();
$iHeight = $frame->getImageHeight();
$wWidth = $watermark->getImageWidth();
$wHeight = $watermark->getImageHeight();
if ($iHeight < $wHeight || $iWidth < $wWidth) {
// resize the watermark
$watermark->scaleImage($iWidth, $iHeight);
// get new size
$wWidth = $watermark->getImageWidth();
$wHeight = $watermark->getImageHeight();
}
$bgframe = new Imagick();
$bgframe->newImage(($iWidth), ($iHeight + 80), new ImagickPixel('Black'));
$bgframe->setImageDelay($frame->getImageDelay());
$x = ($iWidth) - $wWidth - 5;
$y = ($iHeight + 80) - $wHeight - 5;
$bgframe->compositeImage($frame, imagick::COMPOSITE_DEFAULT, 0, 0);
$bgframe->flattenImages();
$bgframe->compositeImage($watermark, imagick::COMPOSITE_OVER, $x, $y);
$bgframe->flattenImages();
$GIF->addImage($bgframe);
}
$GIF->writeimages($imagepath,true);