LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 10-03-2010, 03:07 PM   #1
alanv
LQ Newbie
 
Registered: Jun 2010
Distribution: Ubuntu, Debian, Fedora
Posts: 21

Rep: Reputation: 0
Question How can I create a png or jpeg file programatically ?


Hello,

Given a matrix with 0,1 entries, how can I create a graphic in linux such that we have a black square or pixel if the entry is one and white otherwise?

For example, if the matrix is:
0001000
0011100
0111110
0000000
then I want a graphic that looks like:
██████
███████
█████
███████

I will be working with many large matrices, e.g. 1000x1000, or 5000x1000 so I need to do this automatically.

Your help is greatly appreciated.

Alan

Last edited by alanv; 10-03-2010 at 03:10 PM.
 
Old 10-03-2010, 03:10 PM   #2
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Hanover, Germany
Distribution: Gentoo
Posts: 15,346
Blog Entries: 2

Rep: Reputation: 3978Reputation: 3978Reputation: 3978Reputation: 3978Reputation: 3978Reputation: 3978Reputation: 3978Reputation: 3978Reputation: 3978Reputation: 3978Reputation: 3978
Depends on the programming language you want to use. And if you know that, the answer is only one "googling" away.
 
Old 10-03-2010, 03:15 PM   #3
alanv
LQ Newbie
 
Registered: Jun 2010
Distribution: Ubuntu, Debian, Fedora
Posts: 21

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by TobiSGD View Post
Depends on the programming language you want to use. And if you know that, the answer is only one "googling" away.
I know how to do it using software, e.g. matlab, maple, mathematica, etc. I "googled" it and all I found was that type of software. But preferable I would like to use only a sh file.

Anyone has any idea besides telling me to go google it ?
 
Old 10-03-2010, 03:15 PM   #4
markush
Senior Member
 
Registered: Apr 2007
Location: Germany
Distribution: Slackware
Posts: 3,970

Rep: Reputation: 848Reputation: 848Reputation: 848Reputation: 848Reputation: 848Reputation: 848Reputation: 848
Hello alanv,

you should google for svg (scalable vector graphics)or xpm. xpm should meet your requirements.

Markus

Last edited by markush; 10-03-2010 at 03:16 PM.
 
1 members found this post helpful.
Old 10-03-2010, 03:21 PM   #5
John VV
Guru
 
Registered: Aug 2005
Posts: 12,597

Rep: Reputation: 1677Reputation: 1677Reputation: 1677Reputation: 1677Reputation: 1677Reputation: 1677Reputation: 1677Reputation: 1677Reputation: 1677Reputation: 1677Reputation: 1677
use imagemagick's c++ hooks
or from the terminal

you and also use " CImg.h" in the program code
there are about 100 different things and a 100 different ways
 
Old 10-03-2010, 03:21 PM   #6
alanv
LQ Newbie
 
Registered: Jun 2010
Distribution: Ubuntu, Debian, Fedora
Posts: 21

Original Poster
Rep: Reputation: 0
Thumbs up

Quote:
Originally Posted by markush View Post
Hello alanv,
you should google for svg (scalable vector graphics)or xpm. xpm should meet your requirements.
Markus
Great! I think xpm is what I was looking for. I will leave the thread open for a while in case there are more suggestions.

Thanks

Alan
 
Old 10-03-2010, 03:42 PM   #7
alanv
LQ Newbie
 
Registered: Jun 2010
Distribution: Ubuntu, Debian, Fedora
Posts: 21

Original Poster
Rep: Reputation: 0
When looking for xpm, I found pbm and it is the best option for my needs.

The format would be

P1
7 4
0001000
0011100
0111110
0000000

and then I would save it as pbm, that's it. It would directly handle the matrix. This can easily be done with a sh file (I would just need to add P1 and the size of the matrix).

Thanks.

Alan
 
  


Reply

Tags
graphic, jpeg, png


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] retrieving jpeg files from BkUp copy yields:ERR INTERPRETING JPEG; file not jpeg, drmjh Linux - General 7 10-03-2010 08:13 AM
Html file to Jpeg or Png? akihandyman Mandriva 2 10-02-2004 10:00 AM
php dynamically create transparent png j-ray Programming 2 08-29-2004 08:41 AM
Image conversor bmp & png to jpeg Adony Linux - Software 2 06-19-2004 03:43 PM
jpeg and png library for gd upr8830 Linux - Software 4 06-11-2003 04:49 PM


All times are GMT -5. The time now is 04:58 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration