Two things about your function:
1) If you pass a string which is not oine of the names tested for, the function's resultis indeterminate; and
2) you do exactly the same thing when the name is a known one.
All of which means that instead of that "if" chain you can implement it as:
function TForm1.getImgControl(str: String): TImage;
var
AComponent: TComponent;
begin
AComponent := FindComponent(str);
if Assigned(AComponent) and AComponent.InheritsFrom(TImage) then
Result := TImage(AComponent)
else
Result := Nil;
end;
Note that it will then return
Nil if the name is not that of a TImage so you should check for this whenever it's used:
procedure TForm1.Button1Click(Sender: TObject);
var
str: String;
Img: TImage;
begin
str:='Style_01'; //just for testing
Img := getImgControl(str);
if Assigned(Img) then
Img.AutoSize:=True;
end;