简体   繁体   English

Swift,如何调整图像大小、添加填充和背景?

[英]Swift, how to resize, add padding and background to an image?

I'm trying to create so simple image processing on a macOS app using Swift, to start a have a file URL (eg "../myFiles/myFile.png"), I would like to add paddings to the image and give it a background.我正在尝试使用 Swift 在 macOS 应用程序上创建如此简单的图像处理,以启动一个文件 URL(例如“../myFiles/myFile.png”),我想为图像添加填充并给它一个背景。

Here is one example, this would be the original image:这是一个示例,这将是原始图像:

原始图像

And this is the final result I would like to obtain:这是我想获得的最终结果:

在此处输入图像描述

Any idea on how to achieve this (preferably applying shadows)?关于如何实现这一点的任何想法(最好应用阴影)?

PS I took a look into some swift libraries but they seem very low level (eg https://github.com/koher/swift-image ), I don't know how to achieve what I want with them PS 我查看了一些 swift 库,但它们似乎非常低级(例如https://github.com/koher/swift-image ),我不知道如何用它们实现我想要的

For those looking for a solution using the native APIs the source code of my (now defunct app) is open source:对于那些使用本机 API 寻找解决方案的人,我的(现在已失效的应用程序)的源代码是开源的:

https://github.com/ospfranco/messer https://github.com/ospfranco/messer

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM