# 内联预览图像有时左右会被裁剪一个像素

**URL:** <https://meta.discourse.org/t/inline-preview-images-are-sometimes-cut-off-left-or-right-by-one-pixel/109941>\
**Category:** Support\
**Created:** [2019年二月24日 10:26 UTC](https://meta.discourse.org/t/inline-preview-images-are-sometimes-cut-off-left-or-right-by-one-pixel/109941 "2019-02-24T10:26:58Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![uwe\_keim](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/uwe_keim/32/326762_2.png) [@uwe\_keim](https://meta.discourse.org/u/uwe_keim)\
**Post date:** [2019年二月24日 10:26 UTC](https://meta.discourse.org/t/inline-preview-images-are-sometimes-cut-off-left-or-right-by-one-pixel/109941/1 "2019-02-24T10:26:58Z")

</div>

Example here:

> **[Deutsches .NET Framework Sprachpaket auf einem englischen Windows Server 2016...](https://entwicklergate.de/t/deutsches-net-framework-sprachpaket-auf-einem-englischen-windows-server-2016-installieren/358/1)**
>
> Symptom In einer Anwendung mit ASP.NET MVC wurden (Fehler-)Meldungen, die aus dem .NET Framework generiert wurden in englisch ausgegeben, obwohl die Culture der Anwendung auf deutsch eingestellt war. Ursache Die Ursache war, dass für das .NET...

There are several screenshots in the above posting, and when it comes to fully white windows with a one pixel wide border, these borders sometimes get cut off left or right.

It only happens in the preview.

This looks rather ugly, because when a white window on a white website is shown, the user sees no visual border.

I sometimes add a one-pixel transparent border left or right, to outsmart the scaling algorithm.

**My question:**

Is there something I can configure to make the scaling algorithm for images work perfectly, even for the leftmost and rightmost pixels of an image?

---

<div class="post-metadata">

**Author:** ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)\
**Post date:** [2019年二月24日 11:43 UTC](https://meta.discourse.org/t/inline-preview-images-are-sometimes-cut-off-left-or-right-by-one-pixel/109941/2 "2019-02-24T11:43:47Z")

</div>

Why not add the border using CSS?

---

<div class="post-metadata">

**Author:** ![uwe\_keim](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/uwe_keim/32/326762_2.png) [@uwe\_keim](https://meta.discourse.org/u/uwe_keim)\
**Post date:** [2019年二月24日 14:44 UTC](https://meta.discourse.org/t/inline-preview-images-are-sometimes-cut-off-left-or-right-by-one-pixel/109941/3 "2019-02-24T14:44:52Z")

</div>

Sounds like a lot of effort for something that the tools should do automatically in my opinion.

---

<div class="post-metadata">

**Author:** ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)\
**Post date:** [2019年二月24日 14:48 UTC](https://meta.discourse.org/t/inline-preview-images-are-sometimes-cut-off-left-or-right-by-one-pixel/109941/4 "2019-02-24T14:48:43Z")

</div>

It’s 1 line of css.

Also, we can’t predict how ImageMagick will scale down an image. We can’t ensure that 1 pixel borders are never removed…

---

<div class="post-metadata">

**Author:** ![uwe\_keim](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/uwe_keim/32/326762_2.png) [@uwe\_keim](https://meta.discourse.org/u/uwe_keim)\
**Post date:** [2019年二月24日 19:01 UTC](https://meta.discourse.org/t/inline-preview-images-are-sometimes-cut-off-left-or-right-by-one-pixel/109941/5 "2019-02-24T19:01:34Z")

</div>

How about something like this?

> <https://stackoverflow.com/questions/49845736/imagemagick-resize-with-borders-in-batch>

---

<div class="post-metadata">

**Author:** ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)\
**Post date:** [2019年二月24日 19:21 UTC](https://meta.discourse.org/t/inline-preview-images-are-sometimes-cut-off-left-or-right-by-one-pixel/109941/6 "2019-02-24T19:21:54Z")

</div>

Sure, feel free to write a whole plugin to overwrite how Discourse generates thumbnails (instead of 1 line of CSS) just to add borders 😉

---

<div class="post-metadata">

**Author:** ![uwe\_keim](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/uwe_keim/32/326762_2.png) [@uwe\_keim](https://meta.discourse.org/u/uwe_keim)\
**Post date:** [2019年二月24日 19:58 UTC](https://meta.discourse.org/t/inline-preview-images-are-sometimes-cut-off-left-or-right-by-one-pixel/109941/7 "2019-02-24T19:58:41Z")

</div>

Actually, I do not want borders. I want the images to be scaled to respect the very left and very right pixels.

---

<div class="post-metadata">

**Author:** ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)\
**Post date:** [2019年二月24日 20:55 UTC](https://meta.discourse.org/t/inline-preview-images-are-sometimes-cut-off-left-or-right-by-one-pixel/109941/8 "2019-02-24T20:55:48Z")

</div>

> [@uwe\_keim](#):
>
> It only happens in the preview.

Why does this matter if it is only in the preview?

---

<div class="post-metadata">

**Author:** ![Stephen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/stephen/32/95011_2.png) [@Stephen](https://meta.discourse.org/u/Stephen)\
**Post date:** [2019年二月24日 21:04 UTC](https://meta.discourse.org/t/inline-preview-images-are-sometimes-cut-off-left-or-right-by-one-pixel/109941/9 "2019-02-24T21:04:07Z")

</div>

> [@uwe\_keim](#):
>
> Actually, I do not want borders. I want the images to be scaled to respect the very left and very right pixels.

But the “solution” you linked **adds borders to every image** , which most sites wouldn’t want. Your problem isn’t with Discourse, it’s _with the way in which images are resampled when ImageMagick scales them down_. Adding a border to the image has more of an impact than the CSS change, which by your own admission you don’t want.

Why not [approach ImageMagick](https://github.com/ImageMagick/ImageMagick/issues) and see if they have a solution rather than blaming Discourse, which isn’t responsible. This isn’t a Discourse problem in the slightest.

---

<div class="post-metadata">

**Author:** ![uwe\_keim](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/uwe_keim/32/326762_2.png) [@uwe\_keim](https://meta.discourse.org/u/uwe_keim)\
**Post date:** [2019年二月25日 08:31 UTC](https://meta.discourse.org/t/inline-preview-images-are-sometimes-cut-off-left-or-right-by-one-pixel/109941/10 "2019-02-25T08:31:05Z")

</div>

I tried to explain this:

> …when a white window on a white website is shown, the user sees no visual border.

---

<div class="post-metadata">

**Author:** ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)\
**Post date:** [2022年三月26日 07:48 UTC](https://meta.discourse.org/t/inline-preview-images-are-sometimes-cut-off-left-or-right-by-one-pixel/109941/11 "2022-03-26T07:48:57Z")

</div>



---

<div class="post-metadata">

**Author:** ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)\
**Post date:** [2022年三月27日 21:17 UTC](https://meta.discourse.org/t/inline-preview-images-are-sometimes-cut-off-left-or-right-by-one-pixel/109941/12 "2022-03-27T21:17:30Z")

</div>

好的，这张 802x802 的图片边缘有 2px 的紫色边框：

 ![image](https://global.discourse-cdn.com/meta/original/3X/6/3/63d0bde04303c33de08f39fb114efa2b2cdb5a04.png)

我截取了屏幕截图，然后裁剪并放大了角落：

![image](https://global.discourse-cdn.com/meta/original/3X/a/d/ad8b5585bc90ecf01ce54cb60c045d8af9f8b855.png)

现在看起来还可以，所以也许这个问题在后端已经被修复了。

---

<div class="post-metadata">

**Author:** ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)\
**Post date:** [2022年三月27日 21:20 UTC](https://meta.discourse.org/t/inline-preview-images-are-sometimes-cut-off-left-or-right-by-one-pixel/109941/13 "2022-03-27T21:20:17Z")

</div>


