# Luxor 'placeimage' with scaling

**URL:** <https://discourse.julialang.org/t/luxor-placeimage-with-scaling/114299>\
**Category:** Visualization\
**Tags:** question, package, luxor\
**Created:** [May 15, 2024, 1:57pm UTC](https://discourse.julialang.org/t/luxor-placeimage-with-scaling/114299 "2024-05-15T13:57:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![beryl](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/beryl/32/209986_2.png) [@beryl](https://discourse.julialang.org/u/beryl)\
**Post date:** [May 15, 2024, 1:57pm UTC](https://discourse.julialang.org/t/luxor-placeimage-with-scaling/114299/1 "2024-05-15T13:57:19Z")

</div>

Hi, I think this is a rather simple question but somehow I am unable to figure this out… 😅

So, I have some svg images where all of them have the same scales. I want to place them on some absolute coordinates with varying scales.

I know that it is possible to do this by playing with `@layer`, the code will be more or less looks like:

```julia
# imgs, coords, scales, are the data vectors 
Drawing(some_w, some_h, "test.svg")
for (i,img) in enumerate(imgs)
    origin()
    translate(coords[i])
    @layer begin
        scale(scales[i])
        placeimage(img, O)
    end
end

```

I guess my question is, is there any simpler way of doing this without changing the global scaling and then resetting it (then repeat)? Maybe something like `placeimage(img, coor; scale=scale)`? Thanks.

---

<div class="post-metadata">

**Author:** ![cormullion](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cormullion/32/49131_2.png) [@cormullion](https://discourse.julialang.org/u/cormullion)\
**Post date:** [May 15, 2024, 5:21pm UTC](https://discourse.julialang.org/t/luxor-placeimage-with-scaling/114299/2 "2024-05-15T17:21:29Z")

</div>

> [@beryl](#):
>
> , is there any simpler way of doing this without changing the global scaling and then resetting it (then repeat)? Maybe something like `placeimage(img, coor; scale=scale)` ?

Not really. Luxor uses a simple “current state” model, rather than have keywords for transformations in every function. But you can easily add a helper function of your own:

```julia
svgplace(svg, pos; scalefactor = 1) = @layer begin 
    scale(scalefactor)
    placeimage(svg, pos)
end

@draw begin
    svgplace(svgimg, O, scalefactor=0.1)
    svgplace(svgimg, Point(100, 100), scalefactor=0.5)
end

```

---

<div class="post-metadata">

**Author:** ![beryl](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/beryl/32/209986_2.png) [@beryl](https://discourse.julialang.org/u/beryl)\
**Post date:** [May 15, 2024, 6:17pm UTC](https://discourse.julialang.org/t/luxor-placeimage-with-scaling/114299/3 "2024-05-15T18:17:51Z")

</div>

> [@cormullion](#):
>
> ```julia
> svgplace(svg, pos; scalefactor = 1) = @layer begin 
> scale(scalefactor)
> placeimage(svg, pos)
> end
> 
> ```

This function would place the scaled `svgimage` at `pos*scalefactor` right?, (I could be wrong though). My goal is placing the scaled `svgimage` at `pos` (maybe my explanation was unclear, my bad). Hence why I also used `origin` and `translate` (kinda a roundabout way to `placeimage` at `pos` without being affected by the `scalefactor`).
