mirror of
https://github.com/ZeroHawkeye/wordZero.git
synced 2025-09-26 20:01:17 +08:00
Page:
en Image Operations
Pages
01 快速开始
02 基础功能
03 样式系统
04 文本格式化
05 表格操作
06 页面设置
07 图片操作
08 高级功能
09 最佳实践
10 API参考
11 示例项目
12 模板功能
13 性能基准测试
14 功能特性详览
15 项目结构详解
16 Markdown双向转换
Home
en API Reference
en Advanced Features
en Basic Features
en Best Practices
en Example Projects
en Feature Overview
en Home
en Image Operations
en Markdown Conversion
en Page Settings
en Performance Benchmarks
en Project Structure
en Quick Start
en Style System
en Table Operations
en Template Features
en Text Formatting
Clone
1
en Image Operations
zero edited this page 2025-06-05 09:38:49 +08:00
Image Operations
WordZero provides comprehensive image manipulation capabilities for inserting, positioning, and styling images in Word documents. This chapter covers image insertion, sizing, positioning, and advanced image features.
🖼️ Image Insertion
Basic Image Insertion
import "github.com/ZeroHawkeye/wordZero/pkg/document"
doc := document.New()
// Insert image from file
image, err := doc.AddImageFromFile("path/to/image.jpg")
if err != nil {
log.Fatal(err)
}
// Insert image from byte data
imageData, _ := ioutil.ReadFile("image.png")
image2 := doc.AddImageFromBytes(imageData)
Image Formats
WordZero supports multiple image formats:
// Supported formats
// JPEG/JPG
doc.AddImageFromFile("photo.jpg")
// PNG (with transparency support)
doc.AddImageFromFile("logo.png")
// GIF
doc.AddImageFromFile("animation.gif")
// BMP
doc.AddImageFromFile("bitmap.bmp")
📐 Image Sizing
Automatic Sizing
// Insert image with original size
image := doc.AddImageFromFile("image.jpg")
// Auto-fit to page width
image.FitToPageWidth()
// Auto-fit to specific width (maintaining aspect ratio)
image.SetWidth(400) // pixels
// Auto-fit to specific height (maintaining aspect ratio)
image.SetHeight(300) // pixels
💡 Best Practices
1. Image Quality
- Use appropriate resolution for your document
- Optimize file sizes for better performance
- Choose the right format for your content
2. Layout Considerations
- Ensure images enhance the content
- Use consistent sizing throughout the document
- Consider text flow around images
3. Accessibility
- Provide alternative text for images
- Ensure sufficient contrast
- Use images that support your message
Next Steps
Continue learning about document features:
- Advanced Features - Complex document elements
- Best Practices - Optimization techniques
- Template Features - Dynamic content
Master image operations to create visually appealing documents!