JPEG export producing images with black background

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

JPEG export producing images with black background

Usman Bhatti
I need to export JPEG images in Pharo to later import then in my PDF document. When I export JPEG files with Pharo, the background is black, which makes the exported image meaningless. To reproduce the problem, do the following in the latest moose image (the image can be obtained from here):

|window|
window := ESExamples new kiviat2.
window model canvas imageForm writeJPEGfileNamed: 'fileName.jpg'. 

The file will be produced in the image folder. If someone could suggest how to make the background white or transparent, it'll be a great help.

Usman
Reply | Threaded
Open this post in threaded view
|

Re: JPEG export producing images with black background

Benjamin Van Ryseghem (Pharo)
use png.

Jpegs have background, so you will not go very further in this direction (if I understood well your problem ^^)

Ben

On Jun 15, 2013, at 11:56 PM, Usman Bhatti <[hidden email]> wrote:

I need to export JPEG images in Pharo to later import then in my PDF document. When I export JPEG files with Pharo, the background is black, which makes the exported image meaningless. To reproduce the problem, do the following in the latest moose image (the image can be obtained from here):

|window|
window := ESExamples new kiviat2.
window model canvas imageForm writeJPEGfileNamed: 'fileName.jpg'. 

The file will be produced in the image folder. If someone could suggest how to make the background white or transparent, it'll be a great help.

Usman

Reply | Threaded
Open this post in threaded view
|

Re: JPEG export producing images with black background

Usman Bhatti
On Sun, Jun 16, 2013 at 12:00 AM, Benjamin <[hidden email]> wrote:
use png.

Jpegs have background, so you will not go very further in this direction (if I understood well your problem ^^)

The thing is that I am using Artefact framework for PDF images and it uses JPEG plugin for embedding images. Earlier, I tried with exporting PNGs (that have a transparent background) but when importing these PNGs into pdf docs, the JPEGReader adds the colored background (black in my case).

Another solution would be to see if Artefact can allow embedding Forms in Pharo into PDF docs directly (currently it does not) or it can provide a plugin for PNG images.


 

Ben

On Jun 15, 2013, at 11:56 PM, Usman Bhatti <[hidden email]> wrote:

I need to export JPEG images in Pharo to later import then in my PDF document. When I export JPEG files with Pharo, the background is black, which makes the exported image meaningless. To reproduce the problem, do the following in the latest moose image (the image can be obtained from here):

|window|
window := ESExamples new kiviat2.
window model canvas imageForm writeJPEGfileNamed: 'fileName.jpg'. 

The file will be produced in the image folder. If someone could suggest how to make the background white or transparent, it'll be a great help.

Usman


Reply | Threaded
Open this post in threaded view
|

Re: JPEG export producing images with black background

Olivier Auverlot
Hi Husman,

A little piece of code to use an intermediate morph that has not a transparency background. When the morph is exported, the JPEG file is correct.

|window m graph |
window := ESExamples new kiviat2.

graph := window model canvas imageForm asMorph.
m := Morph new extent: graph extent; color: Color white.
m addMorph: graph; position: 1@1.
m imageForm writeJPEGfileNamed: 'test.jpg'

We can probably do best

Hope that can help you
Olivier ;-)


Le 16 juin 2013 à 09:49, Usman Bhatti a écrit :

On Sun, Jun 16, 2013 at 12:00 AM, Benjamin <[hidden email]> wrote:
use png.

Jpegs have background, so you will not go very further in this direction (if I understood well your problem ^^)

The thing is that I am using Artefact framework for PDF images and it uses JPEG plugin for embedding images. Earlier, I tried with exporting PNGs (that have a transparent background) but when importing these PNGs into pdf docs, the JPEGReader adds the colored background (black in my case).

Another solution would be to see if Artefact can allow embedding Forms in Pharo into PDF docs directly (currently it does not) or it can provide a plugin for PNG images.


 

Ben

On Jun 15, 2013, at 11:56 PM, Usman Bhatti <[hidden email]> wrote:

I need to export JPEG images in Pharo to later import then in my PDF document. When I export JPEG files with Pharo, the background is black, which makes the exported image meaningless. To reproduce the problem, do the following in the latest moose image (the image can be obtained from here):

|window|
window := ESExamples new kiviat2.
window model canvas imageForm writeJPEGfileNamed: 'fileName.jpg'. 

The file will be produced in the image folder. If someone could suggest how to make the background white or transparent, it'll be a great help.

Usman



Reply | Threaded
Open this post in threaded view
|

Re: JPEG export producing images with black background

Usman Bhatti
On Sun, Jun 16, 2013 at 2:24 PM, Olivier Auverlot <[hidden email]> wrote:
Hi Husman,

A little piece of code to use an intermediate morph that has not a transparency background. When the morph is exported, the JPEG file is correct.

|window m graph |
window := ESExamples new kiviat2.

graph := window model canvas imageForm asMorph.
m := Morph new extent: graph extent; color: Color white.
m addMorph: graph; position: 1@1.
m imageForm writeJPEGfileNamed: 'test.jpg'


Tx for suggesting the solution, it works for me. I was looking at the ways how background can be altered with JPEG, fortunately, I didn't spend the day doing it ;), 
Less is more :).

usman 
 
We can probably do best

Hope that can help you
Olivier ;-)


Le 16 juin 2013 à 09:49, Usman Bhatti a écrit :

On Sun, Jun 16, 2013 at 12:00 AM, Benjamin <[hidden email]> wrote:
use png.

Jpegs have background, so you will not go very further in this direction (if I understood well your problem ^^)

The thing is that I am using Artefact framework for PDF images and it uses JPEG plugin for embedding images. Earlier, I tried with exporting PNGs (that have a transparent background) but when importing these PNGs into pdf docs, the JPEGReader adds the colored background (black in my case).

Another solution would be to see if Artefact can allow embedding Forms in Pharo into PDF docs directly (currently it does not) or it can provide a plugin for PNG images.


 

Ben

On Jun 15, 2013, at 11:56 PM, Usman Bhatti <[hidden email]> wrote:

I need to export JPEG images in Pharo to later import then in my PDF document. When I export JPEG files with Pharo, the background is black, which makes the exported image meaningless. To reproduce the problem, do the following in the latest moose image (the image can be obtained from here):

|window|
window := ESExamples new kiviat2.
window model canvas imageForm writeJPEGfileNamed: 'fileName.jpg'. 

The file will be produced in the image folder. If someone could suggest how to make the background white or transparent, it'll be a great help.

Usman