title: Find dynamic image on sikuliX created problems with buffer
body: <p>I'm trying to find an image that I create previously inside an empty template with this function that insert text on it receiving color, content and font and return the path of generate image:</p>
  
  <p><a href="https://i.stack.imgur.com/qJhEc.png" rel="nofollow noreferrer">the template</a></p>
  
  <pre><code>public String insertTextOnBlanck(String colorLetter,String text,Font font) {
      //path is a private varibable initialized with the constructor
      File blankFile = new File("images/dinamic/"+path);
      BufferedImage image = null;
      String exit_path = null;
      try {
          image = ImageIO.read(blankFile);
          int type = image.getType() == 0? BufferedImage.TYPE_INT_ARGB : image.getType();
          Graphics2D g2 = image.createGraphics();
          FontMetrics metrics = g2.getFontMetrics(font);
          BufferedImage resizeImage = resizeImage(image,type, text,metrics);
          image.flush();
          int w = resizeImage.getWidth();
          int h = resizeImage.getHeight();
          g2 = resizeImage.createGraphics();
          g2.setColor(Color.decode(colorLetter));
          g2.setFont(font);
          // Get the FontMetrics
          int x = (w - metrics.stringWidth(text)) / 2;
          int y = (metrics.getAscent() + (h - (metrics.getAscent() + metrics.getDescent())) / 2);
          g2.setBackground(Color.decode("#d1e8f8"));
          g2.drawString(text, x, y);
          g2.dispose();
          //create image with text
          exit_path = "images/dinamic/changed_"+path;
  
          File file = new File(exit_path);
          ImageIO.write(resizeImage, "png", file);
          resizeImage.flush();
      } catch (IOException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      }
      return exit_path;
  }
  </code></pre>
  
  <p>and this works the fist time when i call this other function</p>
  
  <pre><code>    public void  dinamicClick(String path,String input,String fontLetter,String colorLetter, int fontType,int size) throws FindFailed {
      DinamicImg DimImg = new DinamicImg();
      DimImg.setPath(path);
      String modPath = DimImg.insertTextOnBlanck(
              colorLetter,
              input,//Inventario de recurso
              new Font(fontLetter,fontType, size)
              );
      Iterator&lt;Match&gt; myIt = s.findAll(modPath);
      while (myIt.hasNext()) {
          Location loc = myIt.next().getTarget();
          s.click(loc);
      }
      myIt.remove();
      removeFile(modPath);
  }
  </code></pre>
  
  <p>the removeFile function is:</p>
  
  <pre><code>private void removeFile(String toRemove) {
      File file = new File(toRemove);
      if(file.delete()){
          System.out.println(file.getName() + " is deleted!");
      }else{
          System.out.println("Delete operation is failed.");
      }
  }
  </code></pre>
  
  <p>The result:</p>
  
  <p><a href="https://i.stack.imgur.com/LHnJl.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LHnJl.png" alt="the result"></a></p>
  
  <p>but next calls dont work at all, just when i change the name of exit path, so i thought was a cache problem but adding <code>ImageIO.setUseCache(false);</code> at start of "insertTextOnBlanck" function still doesn`t work. Im out of ideas please help, thanks.</p>