Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Okay, have finally given up on this and need some help. I've searched the web and have seen folks reply about this topic but the answers given were either a work-around for the person who originally needed help and the answer didn't fulfill the requirements for what I need or the web topic simply doesn't fit.

I'm basically trying to automate print-quality images using the GD module using a 300dpi source image. This source image is a backdrop to a final image that has text / charts / photos applied on top of it using GD. On every variation that I know about for opening and writing a new image file with GD, it will not create anything other than a final output image at 72dpi. I need to automate this because our group has to be able to output up to a dozen print-quality statistical report marketing pieces every month and it is very tedious doing it by hand.

This is being done on Windows 10. GD is at version 2.5 (latest). For my perl config, I have specified just these two load lines:
use GD;
GD::Image->trueColor(1);

I've created test input files at 300dpi (both jpg and png). Just to keep this simple, I've tried every combination of the following:

$source_image = GD::Image->newFromPng("300dpi_test.png",1);
#$source_image = GD::Image->newFromJpeg("300dpi_test.jpg",1);

#$blank_rgb_image = GD::Image->new(2550, 3300, 1 );
#my $blank_rgb_image = GD::Image->newTrueColor(2550, 3300);
#$blank_rgb_image->copy($source_image,0,0,0,0,2550,3300);
#open(F,">300dpi_test_out.png");
open(F,">300dpi_test_out.jpg");
binmode F;
print F $source_image->jpeg(90);
#print F $blank_rgb_image->jpeg(90);
#print F $blank_rgb_image->png;
close(F);

I've tried to tell GD to open the source image with true color support and just dump the source image to a new file. No luck. I've tried opening the source at true color and then creating a new object image using true color (both with the "1" flag AND using the "newTrueColor" method) then copying+pasting the source image to the new image object... neither method works.

Yes, I could inflate the source size of the 300dpi Photoshop file backdrop image and then try to do everything in 72dpi then resample using Photoshop again after the changes are made but these files wind up being huge, the manipulated imaging pixels would be 4x the normal size and it would then require a 3rd party imaging editor to do the conversion back to 300dpi. There has to be a better solution so that everything can be done in the background... just not sure if GD can really do it.

Any help would be appreciated!

In reply to GD @ 300dpi output by themcp

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (3)
As of 2024-06-24 15:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.