1
settings.tex="pdflatex"; // This command is very important!

unitsize(1cm);

// PNG file
label(graphic("image2.png" ,"width=3cm"),(0,0)); // in the same folder.
draw(box((-3,-3),(3,3)));
// JPG file
label(graphic("image1.jpg" ,"width=3cm"),(5,0));
// Asymptote code
picture pic;
unitsize(pic,1cm);
draw(pic,Label("Some texts",Relative(.75)),circle((0,0),1));
add(pic.fit(),(9,0));
// PDF file
label(graphic("image4.pdf" ,"width=3cm"),(15,0));

layer();
// The layer() function can be used to force future objects to be
// drawn on top of the included image

draw(scale(.5)*Label("Some text",LeftSide),(0,0)--(5,0),Arrow,Margin(.5cm,.45cm));
draw(scale(.5)*Label("Some text",LeftSide),(5,0)--(9,0),Arrow,Margin(.35cm,.35cm));
draw(scale(.5)*Label("Some text",LeftSide),(9,0)--(15,0),Arrow,Margin(.4cm,.5cm));

shipout(bbox(2mm,Fill(white)));

enter image description here

Question:

How can I determine the position (as pair) of a graphic (bottom-left and top-right) in the currentpicture ?

(You can replace two different pictures)

  • string graphic(string name, string options=""), it is string type, so I don't know how to do with it! –  Aug 26 '20 at 14:56
  • Note that the graphic command returns a string; TeX is what actually translates that string into a graphic. So you need to get the bounding box of a TeX-generated label to even start on this problem. See https://tex.stackexchange.com/a/153211/484 for a start. – Charles Staats Aug 26 '20 at 15:01
  • @CharlesStaats Yes, I will have a look. –  Aug 26 '20 at 15:05

1 Answers1

2

Something like this?

enter image description here

settings.tex="pdflatex"; 
real usize=1cm;
unitsize(usize);
picture img;
img.unitsize(usize);
label(img,graphic("image1.png", "width=3cm"),(0,0));
add(img);
dot(min(img)/usize,blue+4*bp);
dot(max(img)/usize,red+4*bp);
g.kov
  • 21,864
  • 1
  • 58
  • 95