Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added document/image-effects/gophercolor.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
71 changes: 71 additions & 0 deletions document/image-effects/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
// Copyright 2025 FoxyUtils ehf. All rights reserved.
package main

import (
"log"
"os"

"github.com/unidoc/unioffice/v2/color"
"github.com/unidoc/unioffice/v2/common"
"github.com/unidoc/unioffice/v2/common/license"
"github.com/unidoc/unioffice/v2/document"
"github.com/unidoc/unioffice/v2/measurement"
)

func init() {
// Make sure to load your metered License API key prior to using the library.
// If you need a key, you can sign up and create a free one at https://cloud.unidoc.io
err := license.SetMeteredKey(os.Getenv(`UNIDOC_LICENSE_API_KEY`))
if err != nil {
panic(err)
}
}

func main() {
doc := document.New()
defer doc.Close()

for i := 0; i < 7; i++ {
img, err := common.ImageFromFile("gophercolor.png")
if err != nil {
log.Fatalf("unable to create image: %s", err)
}

imgref, err := doc.AddImage(img)
if err != nil {
log.Fatalf("unable to create image reference: %s", err)
}
anchored, err := doc.AddParagraph().AddRun().AddDrawingAnchored(imgref)
if err != nil {
log.Fatalf("unable to create anchored drawing: %s", err)
}

// Showcase for different supported image effects.

switch i {
case 0:
// Add soft edge with radius equal to 10 points.
anchored.SetSoftEdgeImageEffect(measurement.Point * 10)
case 1:
// Add glow effect with 8 points radius and blue color.
anchored.SetGlowImageEffect(measurement.Point*8, color.Blue)
case 2:
// Add inner shadow effect with 15 points radius, 10 points offset, red color and 150 degrees rotation
anchored.SetInnerShadowImageEffect(measurement.Point*15, measurement.Point*10, color.Red, 150)
case 3:
// Add outer shadow effect with 27 points radius, 10 points offset, and light blue color
anchored.SetOuterShadowImageEffect(measurement.Point*27, measurement.Point*10, color.LightBlue, 0)
case 4:
// Add reflection effect with 1 point radius, 50% initial transparency and 90% size
anchored.SetReflectionImageEffect(measurement.Point, 50, 90)
case 5:
// Add bevel effect
anchored.SetBevelImageEffect()
case 6:
// Add 3D rotation effect
anchored.Set3DRotationImageEffect()
}
}

doc.SaveToFile("image_effects.docx")
}
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ go 1.20
require (
github.com/disintegration/imaging v1.6.2
github.com/go-ole/go-ole v1.3.0
github.com/unidoc/unichart v0.3.0
github.com/unidoc/unioffice/v2 v2.1.0
github.com/unidoc/unipdf/v3 v3.67.0
github.com/unidoc/unichart v0.4.0
github.com/unidoc/unioffice/v2 v2.2.0
github.com/unidoc/unipdf/v3 v3.68.0
)

require (
Expand Down
16 changes: 6 additions & 10 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,11 @@ github.com/gorilla/i18n v0.0.0-20150820051429-8b358169da46 h1:N+R2A3fGIr5GucoRMu
github.com/gorilla/i18n v0.0.0-20150820051429-8b358169da46/go.mod h1:2Yoiy15Cf7Q3NFwfaJquh7Mk1uGI09ytcD7CUhn8j7s=
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/llgcode/draw2d v0.0.0-20231212091825-f55e0c776b44 h1:1ad70i0s40IpMtRm2ST+Nvr03X7mlHWtdALYkFNrlxk=
github.com/llgcode/draw2d v0.0.0-20231212091825-f55e0c776b44/go.mod h1:muweRyJCZ1mZSMiCgYbAicfnwZFoeHpNr6A6QBu+rBg=
github.com/llgcode/draw2d v0.0.0-20240627062922-0ed1ff131195 h1:Vdz2cBh5Fw2MYHWi3ED2PraDQaWEUhNCr1XFHrP4N5A=
github.com/llgcode/draw2d v0.0.0-20240627062922-0ed1ff131195/go.mod h1:1Vk0LDW6jG5cGc2D9RQUxHaE0vYhTvIwSo9mOL6K4/U=
github.com/llgcode/ps v0.0.0-20210114104736-f4b0c5d1e02e h1:ZAvbj5hI/G/EbAYAcj4yCXUNiFKefEhH0qfImDDD0/8=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/richardlehane/msoleps v1.0.3 h1:aznSZzrwYRl3rLKRT3gUk9am7T/mLNSnJINvN0AQoVM=
github.com/richardlehane/msoleps v1.0.3/go.mod h1:BWev5JBpU9Ko2WAgmZEuiz4/u3ZYTKbjLycmwiWUfWg=
github.com/richardlehane/msoleps v1.0.4 h1:WuESlvhX3gH2IHcd8UqyCuFY5yiq/GR/yqaSM/9/g00=
github.com/richardlehane/msoleps v1.0.4/go.mod h1:BWev5JBpU9Ko2WAgmZEuiz4/u3ZYTKbjLycmwiWUfWg=
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
Expand All @@ -55,12 +51,12 @@ github.com/unidoc/pkcs7 v0.2.0 h1:0Y0RJR5Zu7OuD+/l7bODXARn6b8Ev2G4A8lI4rzy9kg=
github.com/unidoc/pkcs7 v0.2.0/go.mod h1:UEzOZUEpJfDpywVJMUT8QiugqEZC29pDq7kdIZhWCr8=
github.com/unidoc/timestamp v0.0.0-20200412005513-91597fd3793a h1:RLtvUhe4DsUDl66m7MJ8OqBjq8jpWBXPK6/RKtqeTkc=
github.com/unidoc/timestamp v0.0.0-20200412005513-91597fd3793a/go.mod h1:j+qMWZVpZFTvDey3zxUkSgPJZEX33tDgU/QIA0IzCUw=
github.com/unidoc/unichart v0.3.0 h1:VX1j5yzhjrR3f2flC03Yat6/WF3h7Z+DLEvJLoTGhoc=
github.com/unidoc/unichart v0.3.0/go.mod h1:8JnLNKSOl8yQt1jXewNgYFHhFm5M6/ZiaydncFDpakA=
github.com/unidoc/unioffice/v2 v2.1.0 h1:nwfQavH0UBSmE61qtNBF/+ewkSMpCQvVQ1iZsfZv0+0=
github.com/unidoc/unioffice/v2 v2.1.0/go.mod h1:dUugJ94ApprtyRU61dc8F2+gCoKfcb9z43wREihIN5k=
github.com/unidoc/unipdf/v3 v3.67.0 h1:t1ZkNX5iFhGLDPN/68MQOPAq4iXK4tTi7ePpSUBWkdo=
github.com/unidoc/unipdf/v3 v3.67.0/go.mod h1:S5BLo/oBIxAaQtB0Lw3wFqPFOY3U1oU+NISbjX9xEBA=
github.com/unidoc/unichart v0.4.0 h1:uXk9ZjbqzKb8Lt2Qv2oM9D2ftNRXvezPevgxQhsTQys=
github.com/unidoc/unichart v0.4.0/go.mod h1:9QsE8RbS0fE7ndHNroeCEFkRPqqk47Qsoj6QSAtcwN0=
github.com/unidoc/unioffice/v2 v2.2.0 h1:ItoaL4Yi4gzrGIo/U1mm2YAaGqpRuIJoFAhH3iBVcWY=
github.com/unidoc/unioffice/v2 v2.2.0/go.mod h1:nVWakAntBDlyo/4nsztCy2Yk/bIxdwjiezlpmF3K9oE=
github.com/unidoc/unipdf/v3 v3.68.0 h1:AM1wKukv75hvCtTbiPb3HSIdHS5RbmR6aYTCE0jiO+A=
github.com/unidoc/unipdf/v3 v3.68.0/go.mod h1:4mQ4E8niuY+30TGxT1e/8aVoSk/nn0yCKfi+kYw98+I=
github.com/unidoc/unitype v0.5.1 h1:UwTX15K6bktwKocWVvLoijIeu4JAVEAIeFqMOjvxqQs=
github.com/unidoc/unitype v0.5.1/go.mod h1:3dxbRL+f1otNqFQIRHho8fxdg3CcUKrqS8w1SXTsqcI=
golang.org/x/crypto v0.33.0 h1:IOBPskki6Lysi0lo9qQvbxiQ+FvsCC/YWOecCHAixus=
Expand Down
Loading