question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

png bottom image flipped

See original GitHub issue

hello,

using the test files attached I got a perfect image from the up, but a wrong image in the bottom:

cairo_example cairo_bottom

As you can see the silkscreen and the drill files should be inversed. Uploading the same files on OSHPark brings to correct images

Gerber-test.zip

This is my test file:

import os
from gerber import load_layer
from gerber.render import RenderSettings, theme
from gerber.render.cairo_backend import GerberCairoContext

GERBER_FOLDER = "C:\\Users\\vincenzo\\Desktop\\Gerber-test\\"
output = "C:\\Users\\vincenzo\\Desktop\\"

# The default style can be overridden by passing a RenderSettings instance to
# render_layer().
# First, create a settings object:
our_settings = RenderSettings(color=theme.COLORS['white'], alpha=0.85)

# Open the gerber files
drill = load_layer(os.path.join(GERBER_FOLDER, 'ATMEGA328.drl'))

copper = load_layer(os.path.join(GERBER_FOLDER, 'ATMEGA328-F_Cu.gbr'))
mask = load_layer(os.path.join(GERBER_FOLDER, 'ATMEGA328-F_Mask.gbr'))
silk = load_layer(os.path.join(GERBER_FOLDER, 'ATMEGA328-F_SilkS.gbr'))

# Create a new drawing context
ctx = GerberCairoContext()

# Draw the copper layer. render_layer() uses the default color scheme for the
# layer, based on the layer type. Copper layers are rendered as
ctx.render_layer(copper)
ctx.render_layer(mask)
ctx.render_layer(silk, settings=our_settings)
ctx.render_layer(drill)

# Write output to png file
ctx.dump(os.path.join(os.path.dirname(__file__), 'cairo_example.png'))

# Clear the drawing
ctx.clear()

# Load the bottom layers
copper = load_layer(os.path.join(GERBER_FOLDER, 'ATMEGA328-B_Cu.gbr'))
mask = load_layer(os.path.join(GERBER_FOLDER, 'ATMEGA328-B_Mask.gbr'))
silk = load_layer(os.path.join(GERBER_FOLDER, 'ATMEGA328-B_SilkS.gbr'))

# Render bottom layers
ctx.render_layer(copper)
ctx.render_layer(mask)
ctx.render_layer(silk, settings=our_settings)
ctx.render_layer(drill)

# Write png file
ctx.dump(os.path.join(os.path.dirname(__file__), 'cairo_bottom.png'))

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
MarinMikaelcommented, Dec 24, 2019

You can also mirror the layer using RenderSettings:

from gerber.render import RenderSettings
ctx.render_layer(drill, settings=RenderSettings(mirror=True))

If you want more control about the appearance of your pcb, RenderSettings is the way to go.

I recommend you to use file.endswith(pattern) to check for patterns instead of for ".." in file.

0reactions
xiaoqiangnobugcommented, Jul 21, 2020

Hello, In the process of using it, I successfully render Gerber files on windows, but when porting to the Ubuntu system, all top layer inversion will appear when combined rendering, and there is no problem with single

file gto2 微信图片_20200721170545

Read more comments on GitHub >

github_iconTop Results From Across the Web

A TGA image converted to PNG is flipped vertically. #3844
When converting a q3map2 -produced external lightmap file from TGA to PNG , the resulting image is vertically flipped.
Read more >
Flip a PNG Vertically - Online PNG Maker
World's simplest online utility that flips PNG pictures vertically. Free, quick, and powerful. Import a PNG – flip it vertically.
Read more >
Leaflet .png image-map with flipped coordinates?
i have a 4096x4096px .png that represents 15000x15000m. ... height: 1024px; border: 1px solid #ccc; margin-bottom: 10px; } </style> </head> ...
Read more >
Flip Images: Free Online Image Flipper - Fotor
Simply open your images in Fotor app, then choose the flip icon at the bottom of your screen. Select either “Flip Horizontally” or...
Read more >
Flip Images to Get a Perfect Shot - Photo Editor - Canva
1. Go to Canva and select any ready-made template. If you’re working on a custom project, click File then Create new design to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found