Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6948055
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:46:21+00:00 2026-05-27T13:46:21+00:00

my action: public function executePreview(sfWebRequest $request) { $this->setLayout(‘layout_preview’); $text=”; $text= $request->getGetParameter(‘text’); $this->img=”; $this->img2=$this->createImage(array(‘font_size’=>10, ‘line_spacing’=>1.5,’font’=>’dejavu’,

  • 0

my action:

  public function executePreview(sfWebRequest $request)
  {
    $this->setLayout('layout_preview');

    $text='';
    $text= $request->getGetParameter('text');
    $this->img='';
     $this->img2=$this->createImage(array('font_size'=>10, 'line_spacing'=>1.5,'font'=>'dejavu', 'angle'=>10, 
      'preset'=>'BRCA', 'text'=>$text));

  }

  public function createImage( $params)
  {
    $x=0;
    $y=0;
    $interval= $params['font_size']*$params['line_spacing'];
    $src_image= imagecreatefromjpeg(sfConfig::get('sf_web_dir').'/images/'.$params['preset'].'.jpg');
    $black = imagecolorallocate($src_image, 0, 0, 0);
    $lines=explode("\n", $params['text']);
    putenv('GDFONTPATH='.join(':',sfConfig::get('app_font_path')));
    $fontname=$params['font'].'.ttf';
    foreach($lines as $i=>$line):

      imagettftext($src_image, $params['font_size'], $params['angle'], $x, $y+$i*$interval, $black, $fontname, $line);

    endforeach;
    return $src_image;
  }

in my template:

<?php   
 imagejpeg($img2);
?>

but when trying to GET /modulename/preview?preview=something&text=somethingelse, it gives an error. viewing the source of the webpage obtained, I see :

<title>InvalidArgumentException: Unable to escape value &quot;NULL&quot;.</title>

Can I not pass resource identifier to the template? What can be a way around that? I need this createImage function elsewhere also, I’m just trying to follow DRY

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T13:46:22+00:00Added an answer on May 27, 2026 at 1:46 pm

    imagejpeg creates the image and returns a boolean, i don’t get why you call it in your view, it should stay to your action, actually i wouldn’t use view at all in your case.

    try something like :

    $this->getResponse()->setHttpHeader('Content-type', 'image/jpeg');
    $this->getResponse()->setContent($src_image);
    $this->setLayout(false);
    

    or directly setting header with PHP and returning sfView::HEADER_ONLY

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My action: public function executeEdit(sfWebRequest $request) { // Get the object $article = $this->getRoute()->getObject();
For example I have: public function executeTestOne(sfWebRequest $request) { $this->value = Doctrine::getTable('Test')->createQuery('a')->where('id = ?',
I created the following interface: <?php interface Action { public function execute(\requests\Request $request, array
this action is generated in symfony 1.2 when you create a module: public function
Take for example the following controller/action: public function indexAction() { return $this->render('TestBundle:TestController:index.html.twig'); } I
This is my action class public Iterator<CgConsultant> getSearchresult() { List<CgConsultant> list =userSearch.getConsultantMatches(searchstring); System.out.println(The size
I have an action like this: public class News : System.Web.Mvc.Controller { public ActionResult
This is what I want to do: class IndexController extends Zend_Controller_Action { public function
Thats basically my code (simplified): class IndexController extends Zend_Controller_Action { public function indexAction(){ $this->view->setBasePath(APPLICATION_PATH
class AboutController extends Zend_Controller_Action { public function init() { /* Initialize action controller here

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.