10
$\begingroup$

Since the default background color on Chemistry.SX is white, any image, whether it has an alpha-channel to it (e.g. PNG with transparency enabled) or not (e.g. JPEG of GIF) looks fine.

However, quoted blocks (second layer of abstraction) have a different color ("Floral White" on main site, and "Solitude" on Meta). Dropping an image with a white background there creates third layer of abstraction, making it look like the image is not the part of the quote, but rather that they belong to the main text (since it also has white background).

Compare these two 2D and 3D graphics for the DAMN molecule:

No background

enter image description here enter image description here

and this:

White background

enter image description here enter image description here

To my eyes version with no background looks more superior in terms of visual appearance and layout. Technically there is virtually no difficulties in switching between both representations back and forth; however I think that preparing the graphics in PNG format with transparent background should be preferred.

What do you think, is it a reasonable suggestion, or just some bells and whistles?

$\endgroup$
8
  • 1
    $\begingroup$ Is there a way to control the size of an image exported from ChemDraw? If there is I might be able to overcome my laziness (usually I simply screenshot). $\endgroup$ Jan 3, 2018 at 0:06
  • $\begingroup$ Sorry, I don't really use ChemDraw; in MarvinSketch this (dpi, resolution, transparency, scaling etc.) can be set once for the image export (File > Export to Image). As a hack, I suspect one can write a script which will launch ImageMagick in the folder with the exported images and perform the necessary operations. $\endgroup$
    – andselisk Mod
    Jan 3, 2018 at 0:09
  • 1
    $\begingroup$ Yeah. ChemDraw save as image seems to have some issues; the size of the image depends on how many chemicals you have... After uploading, one could control the image size using html tags, but simply zooming to the appropriate level + screenshotting is much easier. $\endgroup$ Jan 3, 2018 at 0:20
  • 1
    $\begingroup$ Screenshotting is an option if you have a high-res display, but I have a crappy one and I need to upscale all images so that they have somewhat decent dpi:) Also, ChemDraw is just an overkill for me, as I mostly handle inorganic stuff, plus I never really understood how it works. If it's too much trouble for you, just stick to your regular workflow; in the end, this is not much of a deal. $\endgroup$
    – andselisk Mod
    Jan 3, 2018 at 0:27
  • 1
    $\begingroup$ @orthocresol Yes, you can change the size of the image exported from ChemDraw if you set a different resolution while saving as PNG. See for example this test: chemistry.meta.stackexchange.com/a/2915/7951 $\endgroup$
    – user7951
    Jan 3, 2018 at 6:36
  • 1
    $\begingroup$ I am usually making extensive use of the imgur scaling options. They do fail with transparent backgrounds, therefore I never use that, and I will not change that, as long as imgur doesn't allow SVG images. $\endgroup$ Jan 7, 2018 at 9:24
  • $\begingroup$ @Martin-マーチン Yeah, I never really found a pattern how and why imgur butchers transparent images upon scaling, but the result is always terrible. On the other hand, I never really needed this feature anyway. I suspect one can use nested images so that clicking on a smaller one would open the hi-res in a separate tab. $\endgroup$
    – andselisk Mod
    Jan 7, 2018 at 9:30
  • 1
    $\begingroup$ From all my experience, I found only one pattern: It butchers all images with transparent background. When I am posting images of structures or orbitals, I usually use nested pictures to preserve some space, in the form [![alt][1]][2], where [1] is the automagically truncated, low resolution preview and [2] is the original image. But then again, the programs I use don't produce transparent background, and I hardly ever quote my own images. $\endgroup$ Jan 9, 2018 at 4:29

4 Answers 4

7
$\begingroup$

I generally insert chemical structure diagrams and similar images as already suggested in the question.
First I draw the structure in ChemDraw (in accordance with styles recommended by ACS and IUPAC as far as possible).
I save the image directly from ChemDraw as PNG (not as JPG!) with a transparent background.
For better results on retina screens and similar high-resolution displays, I set the resolution of the saved PNG image to a value that is higher than necessary (usually double size).
Finally I place the image in the post using HTML and force the display size back to the original size (i.e. usually half of the size of the saved PNG image).
For example:

<img src="https://i.stack.imgur.com/dWoLN.png" width="186" alt="5-hydroxycyclopent-2-en-1-one">

5-hydroxycyclopent-2-en-1-one

5-hydroxycyclopent-2-en-1-one

$\endgroup$
7
$\begingroup$

Just so that we have a conclusion: this is one of the many things where it should definitely be preferred, but not enforced.

Not many people post ChemDraw images anyway, Loong and myself are part of a small handful of people.

For ordinary images I don't think I'll bother changing my workflow, but if I see white backgrounds in quotes then I'll try to edit them as per Loong's suggestion.

$\endgroup$
0
4
$\begingroup$

There is one more thing to consider which I recently discovered. Some people use high-contrast system themes, themes with inverted colors or custom CSS, which may render the page as such:

enter image description here

Since images remain untouched, the transparent ones blend-in with the page background (same problem that people face when preparing graphics for the presentations with black background). The only solution I see is to add contrast thin outer layer to every object on the transparent canvas.

But, as other answers suggest, this is often considered too complicated and breaks many workflows; so I guess in the end it's up to OP to decide how deep she/he would go down the rabbit hole in editing own graphics.

$\endgroup$
4
  • 1
    $\begingroup$ Is this a common thing for people to do? $\endgroup$ Jan 9, 2018 at 15:55
  • $\begingroup$ @orthocresol Well, coders like dark backgrounds. In theory, there is less stress for the eyes, especially in the night time when the ambient light is dimmed. Besides, when you switch between dark IDE or text editor to the browser window, sudden bright picture causes troubles. $\endgroup$
    – andselisk Mod
    Jan 9, 2018 at 16:00
  • 1
    $\begingroup$ @andselisk or/and orthocresol: a bit related is this twitter post by Jimmy Kromann, suggesting "convert in.png -negate -modulate 100,100,0 out.png" for generating a similar inversion (2018-Jul-18, twitter.com/jckromann/status/1019563241465315328). $\endgroup$
    – Buttonwood
    Jul 8, 2019 at 21:26
  • $\begingroup$ @Buttonwood Great find and another demonstration how versatile ImageMagick is:) $\endgroup$
    – andselisk Mod
    Jul 8, 2019 at 21:34
4
$\begingroup$

One thing to know about transparent backgrounds is that it breaks Stack Exchange’s (hosted by imgur) image scaling feature.

For instance, take the image with the URL https://i.stack.imgur.com/ZAS5s.png. This image has a white background, and if we append certain modifiers to the file name, we can scale the picture. The result can be seen below.

  • Normal size:
    test image 1
  • Medium thumbnail:
    test image 1

This image has a white background, so it works. However, ChemDraw can also export transparent backgrounds, as for example the file https://i.stack.imgur.com/BAY2Q.png. Here, scaling breaks:

  • Normal size:
    test image 2
  • Medium thumbnail:
    test image 2

Personally, I have no idea how to determine the ‘correct’ size of a ChemDraw image and I’m not really sure I mastered how to set it correctly. So a white background does offer a much more easy way to scale.

$\endgroup$
3
  • $\begingroup$ Yep, that's a good point that should be a rule: no background – no scaling. And the last image though; you owe me new eyes:D $\endgroup$
    – andselisk Mod
    Jan 9, 2018 at 12:05
  • 2
    $\begingroup$ @andselisk invoice will be sent via voicemail as you can’t read it any more ;P $\endgroup$
    – Jan
    Jan 9, 2018 at 12:07
  • $\begingroup$ verified, that ChemDraw (Prime 16) produces really crappy transparent PNGs (image pallete; and noise like there was some lossy transformation), I'd use better software, or send a bug report or complaint, if commercial user.. or maybe that’s just for unregistered version? $\endgroup$
    – mykhal
    Nov 8, 2018 at 14:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .