使用 Java 裁剪/修剪 JPG 文件的空白区域
是否有一个框架能够删除图像的空白(矩形)。我们根据技术图纸创建图像缩略图,遗憾的是这些图纸是 PDF 格式。我们将 PDF 转换为 SVG,然后转换为 JPG。通常技术图纸都很小,现在放在缩略图的左上角:
+---------+----------------------+
| | |
| (image) | |
| | |
+---------+ |
| |
| |
| |
| |
| (empty space) |
| |
| |
+--------------------------------+
那么如何轻松去除空白并缩小 JPG 文件呢?
Is there a framework which is able to remove the white space (rectangular) of an image. We create Image Thumbnails from technical drawings which are unfortunately in PDF format. We convert the PDF to SVG and then to JPG. Often the technical drawings are very small and now placed in the upper left corner of the thumbnail:
+---------+----------------------+
| | |
| (image) | |
| | |
+---------+ |
| |
| |
| |
| |
| (empty space) |
| |
| |
+--------------------------------+
So how can I easily remove the empty space and shrink the JPG file?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
更多
发布评论
评论(3)
它可以在 JAI 中完成,如此线程中所示。或者这是我刚刚编写的一些 Java 代码,可以用来执行此操作:
It can be done in JAI as is demonstrated in this thread. Or here's some Java code I just wrote which can be used to do it:
对于 Android 用户,这里是一个使用 Mike Kwan 的示例 答案:
希望这对某人有帮助 :)
编辑:
伙计们,我刚刚更新了我的答案,因为最后的代码只是修剪图像的末尾,而不是开头。这个效果很好:)
For Android users, here is an example using Mike Kwan Answer:
Hope this help someone :)
EDIT:
Guys, I just updated my answer cuz last code was just trimming the end of the image, not the beginning. This one is working just great :)
这是最快的。
This is the fastest.