We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Image coordinate

How we get image coordinate from extracted images

Hi Naved,


Thanks for your interest in Aspose. Please check following documentation link for searching images and getting their coordinates. Hopefully it will help you to accomplish the task.


Please feel free to contact us for any further assistance.

Best Regards,

Hi Tilal Ahmad


I have used this link and also work with operator (Do) but could not get any solution.
I got zero count of image placement properties.Any other idea or what will i wrong.

Hi Naved,


Thanks for your feedback. Please share your sample source document here, we will look into it and will guide you accordingly.

We are sorry for the inconvenience caused.

Best Regards,

Hi


here are my source code:
//open document
Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document(Path.Combine(dirPath, file));

// Create ImagePlacementAbsorber object to perform image placement search
Aspose.Pdf.ImagePlacementAbsorber abs = new ImagePlacementAbsorber();

// Accept the absorber for first page
pdfDocument.Pages.Accept(abs);
// Display image placement properties for all placements
foreach (Aspose.Pdf.ImagePlacement imagePlacement in abs.ImagePlacements)
{
Console.Out.WriteLine(“image width:” + imagePlacement.Rectangle.Width);
Console.Out.WriteLine(“image height:” + imagePlacement.Rectangle.Height);
Console.Out.WriteLine(“image LLX:” + imagePlacement.Rectangle.LLX);
Console.Out.WriteLine(“image LLY:” + imagePlacement.Rectangle.LLY);
Console.Out.WriteLine(“image horizontal resolution:” + imagePlacement.Resolution.X);
Console.Out.WriteLine(“image vertical resolution:” + imagePlacement.Resolution.Y);
}

Hi


I have also used this :

//open document
Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document(Path.Combine(dirPath, file));
//IList<Aspose.Note.Image> nodes = pdfDocument.GetChildNodes<Aspose.Note.Image>();
// Define the default resolution for image
int defaultResolution = 72;
System.Collections.Stack graphicsState = new System.Collections.Stack();
// Define array list object which will hold image names
System.Collections.ArrayList imageNames = new System.Collections.ArrayList(pdfDocument.Pages[1].Resources.Images.Names);
// Insert an object to stack
graphicsState.Push(new System.Drawing.Drawing2D.Matrix(1, 0, 0, 1, 0, 0));

// Get all the operators on first page of document
foreach (Operator op in pdfDocument.Pages[1].Contents)
{
// Use GSave/GRestore operators to revert the transformations back to previously set
Operator.GSave opSaveState = op as Operator.GSave;
Operator.GRestore opRestoreState = op as Operator.GRestore;
// Instantiate ConcatenateMatrix object as it defines current transformation matrix.
Operator.ConcatenateMatrix opCtm = op as Operator.ConcatenateMatrix;
// Create Do operator which draws objects from resources. It draws Form objects and Image objects
Operator.Do opDo = op as Operator.Do;

if (opSaveState != null)
{
// Save previous state and push current state to the top of the stack
graphicsState.Push(((System.Drawing.Drawing2D.Matrix)graphicsState.Peek()).Clone());
}
else if (opRestoreState != null)
{
// Throw away current state and restore previous one
graphicsState.Pop();
}
else if (opCtm != null)
{
System.Drawing.Drawing2D.Matrix cm = new System.Drawing.Drawing2D.Matrix(
(float)opCtm.Matrix.A,
(float)opCtm.Matrix.B,
(float)opCtm.Matrix.C,
(float)opCtm.Matrix.D,
(float)opCtm.Matrix.E,
(float)opCtm.Matrix.F);

// Multiply current matrix with the state matrix
((System.Drawing.Drawing2D.Matrix)graphicsState.Peek()).Multiply(cm);

continue;
}
else if (opDo != null)
{
// In case this is an image drawing operator
if (imageNames.Contains(opDo.Name))
{
System.Drawing.Drawing2D.Matrix lastCTM = (System.Drawing.Drawing2D.Matrix)graphicsState.Peek();
// Create XImage object to hold images of first pdf page
XImage image = pdfDocument.Pages[1].Resources.Images[opDo.Name];

// Get image dimensions
double scaledWidth = Math.Sqrt(Math.Pow(lastCTM.Elements[0], 2) + Math.Pow(lastCTM.Elements[1], 2));
double scaledHeight = Math.Sqrt(Math.Pow(lastCTM.Elements[2], 2) + Math.Pow(lastCTM.Elements[3], 2));
// Get Height and Width information of image
double originalWidth = image.Width;
double originalHeight = image.Height;

// Compute resolution based on above information
double resHorizontal = originalWidth * defaultResolution / scaledWidth;
double resVertical = originalHeight * defaultResolution / scaledHeight;

// Display Dimension and Resolution information of each image
Console.Out.WriteLine(
string.Format(“image {0} ({1:.##}:{2:.##}): res {3:.##} x {4:.##}”,
opDo.Name, scaledWidth, scaledHeight, resHorizontal,
resVertical));
}
}
}


In this imageNames three images but Operator.Do contains null.

Hi Naved,


Thanks for sharing your source code. But as requested above, please share your sample source document as well.

We are sorry for the inconvenience caused.

Best Regards,

Hi


Thanks a lot for your support.
I got solution when i reached my minor mistake on my code.
I did not add licence file.


Hi Naved,


Thanks for your feedback. It is good to know that you have managed to accomplish your requirement.

Please keep using our API and feel free to contact us for any further assistance, we will be more than happy to extend our support.

Best Regards,