如何裁剪来自java方面的动态图像?

时间:2016-12-29 06:39:49

标签: html5 css3

我从Java服务的url获取图像。图像尺寸太大。

如何使用内联css减小它的大小?

图像从顶部和底部包含大量白色边框。我也需要删除它。

1 个答案:

答案 0 :(得分:0)

请记住,StackOverflow不是为了完成你的工作而做的。请在下次自己尝试并在咨询SO之前谷歌搜索你想要的东西。

如果你谷歌 css3剪切图片,这里的前两个链接,或多或少都与你想要的一样:

无论如何,这里有一个可能的解决方案,你使用inline-css:

dput(el) structure(list(nr = 1:62, site_id = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L), value1 = c(0.135956723, 0.244470396, 0.986831591, 0.272748803, 0.089672362, 0.087918874, 0.29432428, 0.281550906, 0.491512301, 0.202822283, 0.636965524, 0.439072133, 0.512626669, 0.076218623, 0.537676093, 0.410301432, 0.704414491, 0.028086268, 0.934842257, 0.319693894, 0.038503085, 0.724755387, 0.933940599, 0.293119698, 0.206668204, 0.931947832, 0.570267962, 0.153459278, 0.761549617, 0.168553595, 0.125666771, 0.072239583, 0.585168488, 0.434769948, 0.693265848, 0.507971072, 0.784221012, 0.625158967, 0.734257194, 0.745229936, 0.40953356, 0.070758169, 0.468803818, 0.482476343, 0.329618097, 0.690907203, 0.043867132, 0.335846451, 0.910523185, 0.337186798, 0.94565722, 0.468518602, 0.269354849, 0.357422627, 0.660574954, 0.636926103, 0.558315665, 0.489907305, 0.47082103, 0.808036842, 0.80682936, 0.486316865 ), value2 = c(0.072786841, 0.53838031, 0.41372062, 0.927891345, 0.681514932, 0.099571511, 0.356290822, 0.22791718, 0.222255425, 0.274876628, 0.215780917, 0.679079775, 0.557144492, 0.768317182, 0.209794907, 0.756651704, 0.950439091, 0.394732921, 0.477008544, 0.248762115, 0.452692267, 0.479918885, 0.617401621, 0.107246095, 0.968902896, 0.581772822, 0.654269288, 0.2403724, 0.309798716, 0.305768959, 0.184387495, 0.035095852, 0.513505392, 0.976717695, 0.713275402, 0.948746684, 0.44320735, 0.222039163, 0.440820346, 0.914348945, 0.824638633, 0.392305879, 0.711367921, 0.013197053, 0.990004958, 0.46783633, 0.368384378, 0.105245106, 0.01894147, 0.351691108, 0.689240176, 0.281890828, 0.643299941, 0.295450072, 0.929042677, 0.451298968, 0.087512416, 0.367461399, 0.101109718, 0.388519279, 0.886552629, 0.371934921), value3 = c(0.862942279, 0.306199206, 0.815403468, 0.120029065, 0.120468166, 0.97214058, 0.605333252, 0.381385396, 0.501217425, 0.159266606, 0.712387132, 0.532604745, 0.581300843, 0.764953483, 0.833804202, 0.576785884, 0.739833632, 0.894288301, 0.533339352, 0.454653122, 0.141139261, 0.820376994, 0.804809068, 0.097680334, 0.286965944, 0.610407569, 0.084827216, 0.428986455, 0.080766377, 0.435308821, 0.93199262, 0.453242669, 0.106639551, 0.191650525, 0.807339195, 0.53331683, 0.101494804, 0.952323476, 0.243649472, 0.903883695, 0.265602323, 0.364928386, 0.239852295, 0.388701845, 0.964790214, 0.031507745, 0.922879901, 0.419279331, 0.923975616, 0.370413352, 0.159053801, 0.450200201, 0.262717668, 0.258232936, 0.604593393, 0.625352584, 0.086596067, 0.876201214, 0.95281149, 0.728431032, 0.232121342, 0.53337486)), .Names = c("nr", "site_id", "value1", "value2", "value3"), row.names = c(NA, -62L), class = "data.frame") - 标记与您的图片放在<img>中,该<div>定义&#34;窗口&#34;的大小,我们看看图片的大小(实际大小仍然是同样的。)

这是一个简单的例子:

<div style="height:100px; width:150px; overflow:hidden;">
   <img src="path/to/your/image" />
</div>

我们在这里使用overflow: hidden;,它表示此框中的所有内容都比框本身大,不会显示。要调整图像(由于您的白色边框),请将style="margin-left: 10px";添加到<img> - 标记。你也可以在那里使用负值。