使用PSD.rb gem

时间:2018-04-08 18:30:15

标签: ruby-on-rails ruby rubygems psd

我正在尝试使用PSD.rb gem解析PSD文件。

当我试图获取文本框边界时,它为文本提供了最小的边界框,而不是psd文件中的实际文本矩形尺寸。

此处发布了类似问题:https://github.com/layervault/psd.rb/issues/78 但是,没有适当的解决方案。那么,任何人都可以帮我找到PSD的确切文本框Bounds吗?

提前致谢!

1 个答案:

答案 0 :(得分:0)

获得高度&来自bounds对象的宽度信息:

bounds = layer.adjustments[:type].data[:text]["bounds"]
layer_tree = layer.to_hash
transform = layer_tree[:text][:transform]

top = transform[:ty] + bounds["Top "][:value]
left = transform[:tx]
width = bounds["Rght"][:value]
height = bounds["Btom"][:value] - bounds["Top "][:value]

感谢。