Height and width for jpg to pdf conversion

I have a jpg I want to convert to pdf headlessly. What do I need to do to make the pdf A4 with no white gap around the image? Do I have to scale the jpg beforehand? What is the optimal pixel height and width for a sharp pdf conversion?